note 116337 added to function.basename

From: Date: Mon, 15 Dec 2014 14:30:59 +0000
Subject: note 116337 added to function.basename
Groups: php.notes 
Request: Send a blank email to php-notes+get-201192@lists.php.net to get a copy of this message
As already pointed out above, if a query string contains a '/' character, basename will not handle it well. But it can come really handy when you want to pass a url with query string to a funtion that copies/downloads the file using basename as local filename, by attaching an extra query to the end of the url: <?php $url = 'http://example.com/url?with=query_string'; basename($url); // url?with=query_string $url = $url . '&filename_for_basename=/desired_filename.ext'; basename($url); // desired_filename.ext ?> Note: you can use the filename from the HTTP header (if present) to get the file with it's original filename. ---- Server IP: 72.52.91.14 Probable Submitter: 188.11.246.4 ---- Manual Page -- http://php.net/manual/en/function.basename.php Edit -- https://master.php.net/note/edit/116337 Del: integrated -- https://master.php.net/note/delete/116337/integrated Del: useless -- https://master.php.net/note/delete/116337/useless Del: bad code -- https://master.php.net/note/delete/116337/bad+code Del: spam -- https://master.php.net/note/delete/116337/spam Del: non-english -- https://master.php.net/note/delete/116337/non-english Del: in docs -- https://master.php.net/note/delete/116337/in+docs Del: other reasons-- https://master.php.net/note/delete/116337 Reject -- https://master.php.net/note/reject/116337 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201192) next »