note 84006 added to function.get-included-files
| From: | cleggypdc at gmail dot com | Date: | Mon, 23 Jun 2008 16:47:59 +0000 |
| Subject: | note 84006 added to function.get-included-files | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140743@lists.php.net to get a copy of this message | ||
If you want to get the relative path of an included file, from within itself use this function. If
you ever have a include file thats path may not be static, this can save some time.
function get_current_files_path($file_name)
{
//find the current files directory
$includes = get_included_files();
$path = "";
for ($i=0; $i < count($includes); $i++)
{
$path = strstr($includes[$i], $file_name);
if ($path != false)
{
$key = $i;
break;
}
}
$path = str_replace(getcwd(), "", $includes[$key]);
$path = str_replace("\\", "/", $path);
$path = str_replace($file_name, "", $path);
$path = ltrim($path, "/");
return $path;
}
----
Server IP: 92.48.100.16
Probable Submitter: 86.143.23.100
----
Manual Page -- http://www.php.net/manual/en/function.get-included-files.php
Edit -- https://master.php.net/note/edit/84006
Del: integrated -- https://master.php.net/note/delete/84006/integrated
Del: useless -- https://master.php.net/note/delete/84006/useless
Del: bad code -- https://master.php.net/note/delete/84006/bad+code
Del: spam -- https://master.php.net/note/delete/84006/spam
Del: non-english -- https://master.php.net/note/delete/84006/non-english
Del: in docs -- https://master.php.net/note/delete/84006/in+docs
Del: other reasons-- https://master.php.net/note/delete/84006
Reject -- https://master.php.net/note/reject/84006
Search -- https://master.php.net/manage/user-notes.php