- Forums
- PHP
- PHP How To Show Full Script Path Directory Folder Path
This Page Contains information about PHP How To Show Full Script Path Directory Folder Path By wallpaperama in category PHP with 1 Replies. [1074], Last Updated: Sat May 18, 2024
wallpaperama
Wed Feb 06, 2008
1 Comments
5171 Visits
im putting this post here to remember this important function to show the full path of a script, i use this to display the path of my install script so that i know where the user is installing their script.
CODE
$script_filename = getenv('PATH_TRANSLATED');
if (empty($script_filename)) {
$script_filename = getenv('SCRIPT_FILENAME');
}
$script_filename = str_replace('\', '/', $script_filename);
$script_filename = str_replace('//', '/', $script_filename);
$dir_fs_www_root_array = explode('/', dirname($script_filename));
$dir_fs_www_root = array();
for ($i=0, $n=sizeof($dir_fs_www_root_array)-1; $i<$n; $i++) {
$dir_fs_www_root[] = $dir_fs_www_root_array[$i];
}
$dir_fs_www_root = implode('/', $dir_fs_www_root) . '/';
to show it in your html, just put this:
PHP CODE:
<?php echo $dir_fs_www_root . 'install/myfile.sql'; ?>
https://www.wallpaperama.com/forums/php-how-to-show-full-script-path-directory-folder-path-t5703.html