Say I have a symlink from '/one/directory/'
to '/two/directory/'
.
If I echo dirname(dirname(\__FILE__))
, it returns '/one/directory/'
.
What is the best method to return '/two/directory'
?
Example usage:
Vhost 'example.com'
pointing to `'/two/directory'
example.com/hello_world.php
<?php echo dirname(dirname(__FILE__)); ?>
Returns: '/one/directory'
Expected results: '/two/directory'
<?php
function getRealFile($path) {
return is_link($path) ? readlink($path) : $path;
}
$path = getRealFile(dirname(__FILE__));
Documentation:
http://php.net/manual/en/function.is-link.php
http://php.net/manual/en/function.readlink.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With