On Mar 1, 2015, at 9:07 PM, Umberto Salsi 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?
Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it
Well . is an alias for the current directory, so it would be expected
to work from the
the directory your script is in. By Vista do you mean Windows Vista? I
don't believe
that Windows uses . for the current directory, but I have never worked
on a Windows
platform. I just know that it uses '\ ' for path separator.
Also .. is an alias for the parent directory of the current directory,
so what is
being listed is the parent directory of the the directory your script
is in. As well
Windows, I don't think, uses .. as an alias for the parent directory.
. & .. are standard on any unix workalike platform such as Linux.
JK
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php