|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-07-28 10:27 UTC] d dot reade at ReadesGroupServices dot com
Description:
------------
Using the scandir() method to fetch a list of filenames in a folder. Some filenames contain a space (via SSH this appears as "\ ", i.e. "test\ file.txt"). However PHP sees this file as "test_file.txt". This causes additional file operations such as file_exists() to return false.
Test script:
---------------
<?php
\\ path/to/folder/ contents:
\\ file.txt
\\ test\ file.txt
$scan = scandir('path/to/folder/');
foreach ($scan as $file)
{
echo $file.'
';
}
?>
Expected result:
----------------
file.txt
test\ file.txt
Actual result:
--------------
file.txt
test_file.txt
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 00:00:02 2025 UTC |
Works fine for me using latest SVN 5.3 build: daniel@daniel-laptop:~/tmp$ ls -l total 24 -rw-r--r-- 1 daniel daniel 0 2010-07-28 10:30 foo bar.txt -rw-r--r-- 1 daniel daniel 0 2010-07-28 10:30 helloworld.txt daniel@daniel-laptop:~/tmp$ php -r 'var_dump(scandir("."));' array(4) { [0]=> string(1) "." [1]=> string(2) ".." [2]=> string(11) "foo bar.txt" [3]=> string(14) "helloworld.txt" }