note 32178 deleted from function.basename by bjori
| From: | bjori@php.net | Date: | Tue, 10 Oct 2006 12:27:09 +0000 |
| Subject: | note 32178 deleted from function.basename by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-118346@lists.php.net to get a copy of this message | ||
Note Submitter: travis dot kroh at ndsu dot nodak dot edu
----
<?php
$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")