|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-01-19 13:47 UTC] pajoye@php.net
-Status: Open
+Status: Wont fix
[2011-01-19 13:47 UTC] pajoye@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
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.