note 54442 added to function.basename

From: Date: Mon, 04 Jul 2005 18:55:46 +0000
Subject: note 54442 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-91435@lists.php.net to get a copy of this message
If you find that basename is corrupting the original string, you're seeing this bug: http://bugs.php.net/bug.php?id=15234 To get around it, take a copy of the string and use that in your call to basename. For example: <?php $a=array("x.y"); foreach($a as $b) { $tmp = $b .''; $c=basename($tmp,".y"); print "\$c is '$c'<br>\n"; print $a[0] . "<br>\n"; print $tmp . "<br>\n"; } ?> Gives this: $c is 'x' x.y x Note that $tmp has been corrupted. If you didn't do that assignment with the string concatenation, $b would have been corrupted too. As well as $a[0]. ---- Manual Page -- http://www.php.net/manual/en/function.basename.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54442 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54442&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54442&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54442&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54442&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54442&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54442&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54442&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91435) next »