From: Operating system: Ubuntu 10.04 PHP version: Irrelevant Package: Directory function related Bug Type: Feature/Change Request Bug description:Add support for chdir() without any parameter called
Description: ------------ For consistency with the widely known 'cd' tool and existing functionality from other programming languages, e.g. Perl, I believe that a call to the chdir() function without any parameters should be supported. In Bash and Perl, cd/chdir without any parameters given, changes back to the home directory of the user. As this is pretty convenient (because you usually start in the home directory and can then easier get back), I believe that such a change would also be pretty useful within PHP. Test script: --------------- # dummy script, no useful functionality # to be executed from command line echo "Write something:\n"; $string = trim(fgets(STDIN)); chdir('somedir'); file_put_contents('file', $string); chdir() file_put_contents('file', $string); # or just simply on the command line php -r 'chdir();' Expected result: ---------------- There should be no PHP warning (obviously), we should change back to the user's home directory and the last line file_put_contents('file', $string); should then write the $string variable to /home/johndoe/file Actual result: -------------- $string is written to /home/johndoe/somedir/file (just as expected), however chdir() gives a PHP Warning: chdir() expects exactly 1 parameter, 0 given and aborts the programm. -- Edit bug report at http://bugs.php.net/bug.php?id=53787&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53787&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53787&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53787&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53787&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53787&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53787&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53787&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53787&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53787&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53787&r=support Expected behavior: http://bugs.php.net/fix.php?id=53787&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53787&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53787&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53787&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53787&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53787&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53787&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53787&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53787&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53787&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53787&r=mysqlcfg