PHP How To Show Full Script Path Directory Folder Path
php how to show full script path directory folder path
php, how, to, show, full, script, path, directory, folder, path
PHP How To Show Full Script Path Directory Folder Path
Post Description: php how to show full script path directory folder path
POST# 444
Posted On: Fri Feb 29, 2008 12:01 pm
web hosting
Topic: PHP How To Show Full Script Path Directory Folder Path
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'; ?>




No Repies
(0) Comments for PHP How To Show Full Script Path Directory Folder Path

What do you think?

* name:  

* email:  

* Please enter comments:


Receive Replies on my Comments
(An email will be sent to you when someone replies to your comments)

Add image to comments
yes no             upload