note 23278 rejected from function.urlencode by didou

From: Date: Thu, 29 May 2003 21:04:50 +0000
Subject: note 23278 rejected from function.urlencode by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-49314@lists.php.net to get a copy of this message
Note Submitter: thermalfinder@yahoo.com ---- 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

« previous php.notes (#49314) next »