note 48154 added to function.urlencode
| From: | elqabbany-at-yahoo-dot-com at osu1 dot php dot net | Date: | Tue, 14 Dec 2004 02:27:52 +0000 |
| Subject: | note 48154 added to function.urlencode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81772@lists.php.net to get a copy of this message | ||
It appears that the example above that wraps urlencode() in a call to htmlentities() is just plain
meaningless. The urlencode() function returns a string that only contains the following characters:
alphanumeric
_ (underscore)
- (minus)
. (period)
% (percent)
None of the above characters requires any special html encoding. Thus, wrapping the result of
urlencode() in htmlentities() is confusing and gives no benefit.
Here's the proof:
<?
$str = "abcdefghijklmnopqrstuvwxyzABCDEFHIJKLMNOPQRSTUVWXYZ0123456789_-.%";
$enc = htmlentities($str);
if ($str === $enc) echo "no difference\n";
else echo "they differ\n";
?>
/mme/
----
Manual Page -- http://www.php.net/manual/en/function.urlencode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48154
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48154&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48154&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48154&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48154&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48154&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48154&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48154&report=yes
Search -- http://master.php.net/manage/user-notes.php