note 18773 deleted from function.basename by dams
| From: | dams@php.net | Date: | Wed, 31 Jul 2002 19:11:51 +0000 |
| Subject: | note 18773 deleted from function.basename by dams | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-34072@lists.php.net to get a copy of this message | ||
basename() corrupts the first input when the optional second parameter is used.
This effects global and pre-defined variables, so be careful (E.g. if you use $PHP_SELF - it will be
modified for the lifetime of the script).
To avoid this, place the first paramter in quotes:
$file = "/path/to/file/index.html";
basename($file,".html");
print $file;
// output is: /path/to/file/indexhtml
$file = "/path/to/file/index.html";
basename("$file",".html");
print $file;
// output is: /path/to/file/index.html