What is the script needed to get the current file name of the opened php file? Thanks.
How do I get the file name in PHP?
The constant __FILE__ returns something like:
c:\Inetpub\wwwroot\test\phpinfo.php
This actually is the full physical path of the file containing the line.
Combine it with basename function:
basename( __FILE__ )
returns:
phpinfo.php
Lastly, there is a variable called PHP_SELF in $_SERVER. You can access it as:
$_SERVER[ "PHP_SELF" ]
This gives virtual path of the file:
/test/phpinfo.php
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment