file_put_contents problem
file_put_contents problem
am 14.09.2009 16:19:58 von Andres Gonzalez
I have read in the contents of a file using file_get_contents. I can verify
that the data has actually been read in by echoing its contents.
But then if I do this:
$ret = file_put_contents("/tmp/bla", $bk);
The return value gives the correct size of string $bk, and the file /tmp/bla
is created in /tmp, but the length is 0.
Why are not the contents written to the file?
-Andres
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: file_put_contents problem
am 14.09.2009 16:42:50 von J DeBord
--00c09ffb561b46293e04738aaf2c
Content-Type: text/plain; charset=UTF-8
On Mon, Sep 14, 2009 at 4:19 PM, Andres Gonzalez wrote:
> I have read in the contents of a file using file_get_contents. I can verify
> that the data has actually been read in by echoing its contents.
>
> But then if I do this:
>
> $ret = file_put_contents("/tmp/bla", $bk);
>
> The return value gives the correct size of string $bk, and the file
> /tmp/bla
> is created in /tmp, but the length is 0.
>
> Why are not the contents written to the file?
>
Hmmm. Hard to say.
This works for me:
$contents = 'Testing contents';
var_dump(file_put_contents(APPLICATION_PATH . '/../data/test.txt',
$contents));
Outputs: Int 16 and creates the file test.txt, and writes 'Testing contents'
to the file.
> -Andres
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--00c09ffb561b46293e04738aaf2c--
Re: file_put_contents problem
am 14.09.2009 16:52:08 von List Manager
Andres Gonzalez wrote:
> I have read in the contents of a file using file_get_contents. I can verify
> that the data has actually been read in by echoing its contents.
>
> But then if I do this:
>
> $ret = file_put_contents("/tmp/bla", $bk);
>
> The return value gives the correct size of string $bk, and the file
> /tmp/bla
> is created in /tmp, but the length is 0.
>
> Why are not the contents written to the file?
>
> -Andres
>
We will need to see a little more code before we can make assumptions.
Jim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: file_put_contents problem
am 14.09.2009 16:53:10 von Andres Gonzalez
thank you for your responses.
This appears to be a CodeIgniter problem because everything
of course works fine from a command line script. I will post
a question on their forum.
Thanks again.
-Andres
Jim Lucas wrote:
> Andres Gonzalez wrote:
>
>> I have read in the contents of a file using file_get_contents. I can verify
>> that the data has actually been read in by echoing its contents.
>>
>> But then if I do this:
>>
>> $ret = file_put_contents("/tmp/bla", $bk);
>>
>> The return value gives the correct size of string $bk, and the file
>> /tmp/bla
>> is created in /tmp, but the length is 0.
>>
>> Why are not the contents written to the file?
>>
>> -Andres
>>
>>
>
> We will need to see a little more code before we can make assumptions.
>
> Jim
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: file_put_contents problem
am 14.09.2009 17:15:16 von Ralph Deffke
it would be interesting on what os u are working as well. did u try to open
the file?
on windows often a file is reported as 0 bytes as of failing the refresh in
explorer.
ralph_deffke@yahoo.de
"Andres Gonzalez" wrote in message
news:4AAE510E.8030005@packetstorm.com...
> I have read in the contents of a file using file_get_contents. I can
verify
> that the data has actually been read in by echoing its contents.
>
> But then if I do this:
>
> $ret = file_put_contents("/tmp/bla", $bk);
>
> The return value gives the correct size of string $bk, and the file
/tmp/bla
> is created in /tmp, but the length is 0.
>
> Why are not the contents written to the file?
>
> -Andres
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: file_put_contents problem
am 14.09.2009 18:55:08 von Andres Gonzalez
This is on a Ubuntu 9.04 box. I did not try to open the file but just
listing out
the directory gives the size and it is 0. If I try to cat out the
contents, there is
nothing (I guess that does an open on it)
-Andres
Ralph Deffke wrote:
> it would be interesting on what os u are working as well. did u try to open
> the file?
> on windows often a file is reported as 0 bytes as of failing the refresh in
> explorer.
>
> ralph_deffke@yahoo.de
>
>
> "Andres Gonzalez" wrote in message
> news:4AAE510E.8030005@packetstorm.com...
>
>> I have read in the contents of a file using file_get_contents. I can
>>
> verify
>
>> that the data has actually been read in by echoing its contents.
>>
>> But then if I do this:
>>
>> $ret = file_put_contents("/tmp/bla", $bk);
>>
>> The return value gives the correct size of string $bk, and the file
>>
> /tmp/bla
>
>> is created in /tmp, but the length is 0.
>>
>> Why are not the contents written to the file?
>>
>> -Andres
>>
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php