This is the url of my script: localhost/do/index.php
I want a variable or a function that returns localhost/do
(something like $_SERVER['SERVER_NAME'].'/do'
)
dirname() method in Python is used to get the directory name from the specified path. Parameter: path: A path-like object representing a file system path. Return Type: This method returns a string value which represents the directory name from the specified path.
The accepted answer to Getting the source directory of a Bash script from within addresses getting the path of the script via dirname $0 , which is fine, but that may return a relative path (like . ), which is a problem if you want to change directories in the script and have the path still point to the script's ...
getcwd() method is used for getting the Current Working Directory in Python. The absolute path to the current working directory is returned in a string by this function of the Python OS module.
You can find the Python application path by following these steps: Type “Python” in the Windows Search Bar. Right-click on the Python App, and then select “Open file location“ Right-click again on the Python shortcut, and then select “Open file location“
$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
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