note 23278 added to function.urlencode

From: Date: Sat, 13 Jul 2002 23:07:49 +0000
Subject: note 23278 added to function.urlencode
Groups: php.notes 
Request: Send a blank email to php-notes+get-33031@lists.php.net to get a copy of this message
Another issue I found while using urlencode() is printf, sprintf. Suppose your are building a GET URL for a search page and the user searches for "foo & bar": $userinput = "foo & bar" ; $searchtext = urlencode($userinput) ; // $searchtext now = "foo %26 bar" $format = "<a href='search.php?searchtext=" . $searchtext . "&id=%s&src=%s'>" ; $url = sprintf($format, "123", "456"); If error_reporting(E_WARNING) is set, the following is generated: Warning: sprintf(): too few arguments in c:\dir1\root\test.php on line 4 -- http://www.php.net/manual/en/function.urlencode.php http://master.php.net/manage/user-notes.php?action=edit+23278 http://master.php.net/manage/user-notes.php?action=delete+23278 http://master.php.net/manage/user-notes.php?action=reject+23278

« previous php.notes (#33031) next »