From: ramon_herrera at eloyalty dot com
Operating system: win2k
PHP version: 5.0.0
PHP Bug Type: *Directory/Filesystem functions
Bug description: field consisting of one space char is read as an empty string by
fgetcsv
Description:
------------
A field consisting of one space character is read as an empty string by
the fgetcsv function in version 5.0.0 where the version 4.3.7 fgetcsv
reads the space as it is presented.
The startup .bat file and the CSV file are both listed below.
./test.bat, set to use the PHP 5.0.0 binaries
--------------------------------------------\
@echo off
set PHPROOT=.
REM set PHPVER=4.3.7
set PHPVER=5.0.0
set PHPEXE=%PHPROOT%\bin_%PHPVER%\php.exe
set PHPINI=%PHPROOT%\etc\test.ini
set PHPPHP=%PHPROOT%\usr\test.php
%PHPEXE% -c %PHPINI% -f %PHPPHP%
--------------------------------------------/
./var/zinput.txt
--------------------------------------------\
foo,bar,nextisspace, ,previsspace,last
--------------------------------------------/
Reproduce code:
---------------
<?
define('ZINPUT', 'var/zinput.txt');;
define('FDLM', ',');
define('LLEN', 512);
$fhin = @fopen(ZINPUT, 'rb');
while ( FALSE !== ($s = fgetcsv($fhin, LLEN, FDLM)) )
$inputlines[] = $s;
fclose($fhin);
var_dump($inputlines);
echo "\r\nTested with version " . phpversion() . "\r\n";
?>
Expected result:
----------------
D:\foo>test.bat
array(1) {
[0]=>
array(6) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
string(11) "nextisspace"
[3]=>
string(1) " "
[4]=>
string(11) "previsspace"
[5]=>
string(4) "last"
}
}
Tested with version 4.3.7
D:\foo>
Actual result:
--------------
D:\foo>test.bat
array(1) {
[0]=>
array(6) {
[0]=>
string(3) "foo"
[1]=>
string(3) "bar"
[2]=>
string(11) "nextisspace"
[3]=>
string(0) ""
[4]=>
string(11) "previsspace"
[5]=>
string(4) "last"
}
}
Tested with version 5.0.0
D:\foo>
--
Edit bug report at http://bugs.php.net/?id=29163&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29163&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=29163&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=29163&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29163&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29163&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29163&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29163&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29163&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29163&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29163&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29163&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29163&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29163&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29163&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29163&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29163&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29163&r=float