note 18773 added to function.basename

From: Date: Tue, 05 Feb 2002 04:34:32 +0000
Subject: note 18773 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-26253@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 -- http://www.php.net/manual/en/function.basename.php http://master.php.net/manage/user-notes.php?action=edit+18773 http://master.php.net/manage/user-notes.php?action=delete+18773 http://master.php.net/manage/user-notes.php?action=reject+18773

« previous php.notes (#26253) next »