Re: fopen('.', 'r') succeedes !?
| From: | Peter West | Date: | Mon, 02 Mar 2015 07:16:14 +0000 |
| Subject: | Re: fopen('.', 'r') succeedes !? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-324563@lists.php.net to get a copy of this message | ||
Umberto,
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
Peter West
Peter West
"...and whoever says, ‘You fool! ’ will be liable to the hell of fire"
> On 2 Mar 2015, at 3:07 pm, Umberto Salsi <salsi@icosaedro.it> wrote:
>
> Discovered today: fopen() opens '.' and '..' but fread() returns nothing
> without errors nor end-of-file, so this loop:
>
> $f = fopen('.', 'r');
> if( $f === FALSE ) die("fopen failed");
> $n = 0;
> while(($s = fread($f, 10)) !== FALSE)
> $n += strlen($s);
> fclose($f);
> echo "total bytes read: $n\n";
>
> never ends! The same happens with '..'. Tested on PHP 5.6.3 and 7.0.0
> under Slackware 14.1 32-bits. Under Vista, instead, fopen() fails as
> expected.
>
> Bug or specific feature under Linux?
>