note 69472 added to function.getcwd
| From: | hodgman at ali dot com dot au | Date: | Thu, 07 Sep 2006 02:58:33 +0000 |
| Subject: | note 69472 added to function.getcwd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116798@lists.php.net to get a copy of this message | ||
I use this code to replicate the pushd and popd DOS commands in PHP:
<?php
$g_DirStack = array();
function pushd( $dir )
{
global $g_DirStack;
array_push( $g_DirStack, getcwd() );
chdir( $dir );
}
function popd( )
{
global $g_DirStack;
$dir = array_pop( $g_DirStack );
assert( $dir !== null );
chdir( $dir );
}
?>
This allows you to change the current directory with pushd, then use popd to "undo" the
directory change when you're done.
----
Server IP: 203.220.0.234
Probable Submitter: 203.2.182.254 (proxied: 1.1 AURB-PROXY-03)
----
Manual Page -- http://www.php.net/manual/en/function.getcwd.php
Edit -- https://master.php.net/note/edit/69472
Del: integrated -- https://master.php.net/note/delete/69472/integrated
Del: useless -- https://master.php.net/note/delete/69472/useless
Del: bad code -- https://master.php.net/note/delete/69472/bad+code
Del: spam -- https://master.php.net/note/delete/69472/spam
Del: non-english -- https://master.php.net/note/delete/69472/non-english
Del: in docs -- https://master.php.net/note/delete/69472/in+docs
Del: other reasons-- https://master.php.net/note/delete/69472
Reject -- https://master.php.net/note/reject/69472
Search -- https://master.php.net/manage/user-notes.php