A.php:
<?php
...
?>
How to know the directory within itself?
EDIT On windows,how to change "\" to "/"?
A.php:
<?php
...
?>
How to know the directory within itself?
EDIT On windows,how to change "\" to "/"?
dirname(__FILE__)
to get the path of the PHP file regardless of whether the file runs on its own or is being included by other files.
getcwd()
to get the current working directory (might not be the same as the directory the PHP file is in if it is being included by other files)
By the way, you can get the correct "/" or "\" on any platform by using the DIRECTORY_SEPARATOR constant
And to change separators to the correct one:
$filepath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $filepath);