note 74947 added to function.basename
| From: | egil at wp dot pl | Date: | Sat, 05 May 2007 18:07:01 +0000 |
| Subject: | note 74947 added to function.basename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126219@lists.php.net to get a copy of this message | ||
Using functions like explode if you don't have too, is not a very wise thing to do... A simple
function like the one below should work with any standard query strings.
<?php
function basename_q ($qstring)
{
$q_pos = strpos($qstring,'?');
if ($q_pos===false)
return basename($qstring);
else
return basename(substr($qstring, 0, $q_pos));
}
echo basename_q
('somethin/stuff.php?some=query&other=stuff')."<br/>\n";
echo basename_q ('somethin/stuff.php')."<br/>\n";
?>
The above will output:
stuff.php
stuff.php
----
Server IP: 69.147.83.197
Probable Submitter: 89.79.153.30
----
Manual Page -- http://www.php.net/manual/en/function.basename.php
Edit -- https://master.php.net/note/edit/74947
Del: integrated -- https://master.php.net/note/delete/74947/integrated
Del: useless -- https://master.php.net/note/delete/74947/useless
Del: bad code -- https://master.php.net/note/delete/74947/bad+code
Del: spam -- https://master.php.net/note/delete/74947/spam
Del: non-english -- https://master.php.net/note/delete/74947/non-english
Del: in docs -- https://master.php.net/note/delete/74947/in+docs
Del: other reasons-- https://master.php.net/note/delete/74947
Reject -- https://master.php.net/note/reject/74947
Search -- https://master.php.net/manage/user-notes.php