Re: fopen('.', 'r') succeedes !?
| From: | Umberto Salsi | Date: | Mon, 02 Mar 2015 08:31:51 +0000 |
| Subject: | Re: fopen('.', 'r') succeedes !? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324565@lists.php.net to get a copy of this message | ||
lists@pbw.id.au (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.
Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it