note 26573 added to function.basename
| From: | jrwillia at rack1 dot php dot net | Date: | Tue, 05 Nov 2002 16:07:24 +0000 |
| Subject: | note 26573 added to function.basename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38996@lists.php.net to get a copy of this message | ||
I've found the easiest way to get a dynamic filename is with
$var = basename ($_SERVER["PHP_SELF"],".php");
No REGEXes, no arrays, no registered globals. 8)
This is especially handy in files that get included in other files (e.g. class objects), because the
superglobal assumes the value of the includING page instead of the includED one, so you end up with
a file that dynamically reassigns (in a manner of speaking) the value of $_SERVER[PHP_SELF].
--
http://www.php.net/manual/en/function.basename.php
http://master.php.net/manage/user-notes.php?action=edit+26573
http://master.php.net/manage/user-notes.php?action=delete+26573
http://master.php.net/manage/user-notes.php?action=reject+26573