Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get base directory of current script

Tags:

php

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')

like image 341
cdxf Avatar asked Aug 07 '10 05:08

cdxf


People also ask

How do I get the base of a directory in Python?

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.

How do I get the path of a bash script?

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 ...

How do I find out what directory a Python file is running?

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.

Where is Python scripts folder?

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“


1 Answers

$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']); 
like image 158
www333 Avatar answered Sep 19 '22 17:09

www333