Changing Base Path In PHP

Posted by Joshua on Stack Overflow See other posts from Stack Overflow or by Joshua
Published on 2010-04-23T01:43:35Z Indexed on 2010/04/23 2:03 UTC
Read the original article Hit count: 332

Filed under:

I need to change the folder that "relative include paths" are based on.

I might currently be "in" this folder: C:\ABC\XYZ\123\ZZZ

And in this case, the path "../../Source/SomeCode.php" would actually be in this folder: C:\ABC\XYZ\Source

And realpath('.') would = 'C:\ABC\XYZ\123\ZZZ';

If however, realpath('.') were "C:\Some\Other\Folder"

Then in this case, the path "../../Source/SomeCode.php" would actually be in this folder: C:\Some\Source

How do I change what folder is represented by '.' in realpath()?

Like this:

echo ('BEFORE = '.realpath('.')); // BEFORE = C:\ABC\XYZ\123\ZZZ
// Some PHP code here...
echo ('AFTER = '.realpath('.')); // AFTER = C:\Some\Other\Folder

How can I change the folder represented by '.', as seen by realpath()?

© Stack Overflow or respective owner

Related posts about php