Use PHP to get the functions and server variables for the current url path
- 2020-06-23 00:03:57
- OfStack
PHP gets the function and server variable of the current url path:
Code:
Value returned:
Code:
<?php
$path = /usr/opt/../ect/abcd;
echo $_SERVER['DOCUMENT_ROOT']."<br>"; // Get the server document root variable ( Depending on the http.conf The configuration in )
echo $_SERVER['PHP_SELF']."<br>"; // Gets the path to the file that executes the code, and http.conf The configuration in.
echo __FILE__."<br>"; // Variable that gets the absolute path to the file system for the file
echo dirname(__FILE__); // Function to get the folder path of the file
echo realpath($pah);
?>
Value returned:
/usr/opt/apache2/htdocs/
/alias/aa.php
/usr/opt/apache2/htdocs/kamap/aa.php
/usr/opt/apache2/htdocs/kamap/
/usr/etc/abcd