Page 1 of 1

string in a variable

Posted: Tue Jul 28, 2009 12:03 am
by lordrt
Hello again
I have a PHP statement which goes like this:

$result = fgets($fh);

where $result will store a line read from a text file. I would like to know if the $result var actually contains the strings read, anyone can help?

Re: string in a variable

Posted: Tue Jul 28, 2009 1:51 am
by cpetercarter
fgets() returns 'false' if the operation fails. So you could use a test like

Code: Select all

if ($!result) echo 'An error message';

Re: string in a variable

Posted: Tue Jul 28, 2009 2:54 am
by lordrt
cpetercarter wrote:fgets() returns 'false' if the operation fails. So you could use a test like

Code: Select all

if ($!result) echo 'An error message';
thx will try it

Re: string in a variable

Posted: Tue Jul 28, 2009 10:11 am
by caltoche
I think it's (!$, not $!) :

Code: Select all

if (!$result) echo 'An error message';
No ?

Re: string in a variable

Posted: Wed Jul 29, 2009 1:38 am
by cpetercarter
Yes, you are right!