note 54767 added to function.basename

From: Date: Thu, 14 Jul 2005 16:28:18 +0000
Subject: note 54767 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-91972@lists.php.net to get a copy of this message
Note that in my example below, I used the stripslashes function on the target string first because I was dealing with the POST array $_FILES. When creating this array, PHP will add slashes to any slashes it finds in the string, so these must be stripped out first before processing the file path. Then again, the only reason I can think of that basename() would fail is when dealing with Windows paths on a *nix server -- and the file upload via POST is the only situation I can think of that would require this. Obviously, if you are not dealing with these additional slashes, invoking stripslashes() first would remove the very separators you need extract the file name from the full path. ---- Manual Page -- http://www.php.net/manual/en/function.basename.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54767 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54767&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54767&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54767&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54767&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54767&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54767&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54767&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91972) next »