Re: fopen('.', 'r') succeedes !?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The problem is in the comparison operator, at least in *nixes.

$s may be logically false (== or !=) but they are not of the same value AND type, which, I believe, is what the === and !== operators are looking for.

Peter West
"...and whoever says, ‘You fool! ’ will be liable to the hell of fire"

> On 2 Mar 2015, at 6:31 pm, Umberto Salsi <salsi@xxxxxxxxxxxx> wrote:
> 
> lists@xxxxxxxxx (Peter West) wrote:
> 
>> When I try this in OS X 10.10 php 5.5.14 (I've added newlines to output)
>> $ php -a
>> ...
>> php > $f= fopen('.', 'r');
>> php > print_r( $f );
>> Resource id #2
>> php > $s = fread( $f, 10 );
>> php > print_r(strlen($s));
>> 0
>> php > if ($s !== FALSE) print('NOT FALSE');
>> NOT FALSE
>> php > if ($s != FALSE) print('NOT FALSE');
>> php > if ($s == FALSE) print('IS FALSE');
>> IS FALSE
> 
> I get the same exact result. In fact, var_dump($s) should tell you that
> $s is the empty string. So, fread() is reading nothing forever, rather
> than to return FALSE as the manual page states. Anyway, in my opinion
> fopen should fail immediately trying to open the current directory,
> in the first place.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux