Last active
May 25, 2018 18:45
-
-
Save projectivemotion/c3ca6c7c2ec2022ec547a415618dfb1c to your computer and use it in GitHub Desktop.
Get unresolved path of symlinked php file. Does the opposite of realpath().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns the Symlink (Non-Realpath) of the current script. | |
* I am not so sure how well this function works from inside include's. | |
* Use case: | |
* | |
* [amado@gravedigger phpcode]$ php -f subdir/mysymlink/subdir/mysymlink/subdir/mysymlink/app.php | |
* PWD: /tmp/phpcode | |
* SCRIPT_FILENAME: subdir/mysymlink/subdir/mysymlink/subdir/mysymlink/app.php | |
* ___FILE__ : /tmp/phpcode/app.php | |
* getSymlink(): /tmp/phpcode/subdir/mysymlink/subdir/mysymlink/subdir/mysymlink | |
* | |
* @author: Amado Martinez | |
* @website: http://amadomartinez.mx/ | |
*/ | |
function getSymlink(){ | |
$spath = $_SERVER['SCRIPT_FILENAME']; | |
if($spath[0] != '/') | |
return dirname(getenv('PWD') . '/' . $spath); | |
return $spath; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment