note 32178 added to function.basename

From: Date: Mon, 19 May 2003 19:12:13 +0000
Subject: note 32178 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-48605@lists.php.net to get a copy of this message
$foo="/path/to/file.ext"; echo $foo."<br />"; $bar=$foo; echo basename($bar,".ext")."<br />"; echo $foo."<br />"; echo $bar."<br />"; Will display: /path/to/file.ext file /path/to/file /path/to/file Which is probably not expected behavior, as it returns one thing, changes the variable to produce something else, and also modifies BOTH variables in memory. To avoid this, use: basename(strval($bar),".ext") ---- Manual Page -- http://www.php.net/manual/en/function.basename.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32178 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32178&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32178&report=yes

« previous php.notes (#48605) next »