note 67611 added to function.sprintf

From: Date: Thu, 08 Jun 2006 23:48:29 +0000
Subject: note 67611 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-113963@lists.php.net to get a copy of this message
The example of using argument swapping, or re-using a single argument twice is incorrect. There should be a backslash before the $ sign, otherwise PHP attempts to interpret as a variable. E.g. $foo = sprintf(" ... LIKE '%%%1$s%%' OR foo LIKE '%%%2$s%%'", $myName); should be ... "LIKE '%%%1\$s%%'". Similary for the second definition. Without the backslash, PHP tries to look for the variable "$s" which doesnt exist (or maybe it does in your program, which would create a different error). ---- Server IP: 64.71.164.2 Probable Submitter: 128.114.65.20 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.sprintf.php Edit -- http://master.php.net/note/edit/67611 Del: integrated -- http://master.php.net/note/delete/67611/integrated Del: useless -- http://master.php.net/note/delete/67611/useless Del: bad code -- http://master.php.net/note/delete/67611/bad+code Del: spam -- http://master.php.net/note/delete/67611/spam Del: non-english -- http://master.php.net/note/delete/67611/non-english Del: in docs -- http://master.php.net/note/delete/67611/in+docs Del: other reasons-- http://master.php.net/note/delete/67611 Reject -- http://master.php.net/note/reject/67611 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#113963) next »