note 83856 added to function.urlencode
| From: | php dot net at unixen dot dk | Date: | Sun, 15 Jun 2008 19:53:57 +0000 |
| Subject: | note 83856 added to function.urlencode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140479@lists.php.net to get a copy of this message | ||
>> Hi muthuishere , i saw your excellent contribution, but couldnt make it work, so i
>> corrected some bits and pieces and had the following done:
<?php
function SmartUrlEncode($url){
if (strpos($url, '=') === false):
return $url;
else:
$startpos = strpos($url, "?");
$tmpurl=substr($url, 0 , $startpos+1) ;
$qryStr=substr($url, $startpos+1 ) ;
$qryvalues=explode("&", $qryStr);
foreach($qryvalues as $value):
$buffer=explode("=", $value);
$buffer[1]=urlencode($buffer[1]);
endforeach;
$finalqrystr=implode("&", &$qryvalues);
$finalURL=$tmpurl . $finalqrystr;
return $finalURL;
endif;
}
?>
As you see its very much yours, modfied primarily using '&' instead of
'&', and ofcourse an if test to see if anything in input is to be cursed... Thanks for
great function !
----
Server IP: 195.184.96.15
Probable Submitter: 217.116.243.77
----
Manual Page -- http://www.php.net/manual/en/function.urlencode.php
Edit -- https://master.php.net/note/edit/83856
Del: integrated -- https://master.php.net/note/delete/83856/integrated
Del: useless -- https://master.php.net/note/delete/83856/useless
Del: bad code -- https://master.php.net/note/delete/83856/bad+code
Del: spam -- https://master.php.net/note/delete/83856/spam
Del: non-english -- https://master.php.net/note/delete/83856/non-english
Del: in docs -- https://master.php.net/note/delete/83856/in+docs
Del: other reasons-- https://master.php.net/note/delete/83856
Reject -- https://master.php.net/note/reject/83856
Search -- https://master.php.net/manage/user-notes.php