82711/how-to-get-name-of-current-directory-using-php
I have a php page inside a folder on my website.
I need to add the name of the current directory into a variable for example:
$myVar = current_directory_name;
Is this possible?
Hello @kartik,
To get only the name of the directory where script executed:
//Path to script: /data/html/cars/index.php echo basename(dirname(__FILE__)); //"cars"
OR try this:
getcwd();
or
dirname(__FILE__);
or (PHP5)
basename(__DIR__)
Hope it helps!!
ThanK you!!
Hello @kartik, Try $_SERVER['DOCUMENT_ROOT'] contains this path: D:/workspace In that case you ...READ MORE
Hello @kartik, This will actually get the result ...READ MORE
Hello @kartik, Use this query: SELECT User FROM mysql.user; Which ...READ MORE
Hello @kartik, Use $_SERVER['REQUEST_URI']. The URI which was given in ...READ MORE
Hello @kartik, You don't really access it, you ...READ MORE
Hello @kartik, Single quotes are escaped by doubling ...READ MORE
Hello @kartik, You could use cross-env to set the port, ...READ MORE
Hello @kartik, In version 5.6.5, it is possible ...READ MORE
Hello @kartik, You'll be wanting to use glob() Example: $files = ...READ MORE
Hello @kartik, You can use basename() and $_SERVER['PHP_SELF'] to get current page ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.