note 27346 added to function.sprintf

From: Date: Mon, 02 Dec 2002 20:52:44 +0000
Subject: note 27346 added to function.sprintf
Groups: php.notes 
Request: Send a blank email to php-notes+get-40277@lists.php.net to get a copy of this message
a little note to the argument swapping examples which took me a while to get: if you use single quotes for the format string (like you should do, since there aren't any variable conversions to do as long as you don't need any special chars), the given examples won't work because of the backslash before the $ (needs to be escaped in double quoted strings - but not in single quoted!) so this: $format = "The %2\$s contains %1\$d monkeys"; printf($format,$num,$location); with a single quoted format string would look like this: $format = 'The %2$s contains %1$d monkeys'; printf($format,$num,$location); (no escapes) I hope that helps to avoid confusion ;) -- http://www.php.net/manual/en/function.sprintf.php http://master.php.net/manage/user-notes.php?action=edit+27346 http://master.php.net/manage/user-notes.php?action=delete+27346 http://master.php.net/manage/user-notes.php?action=reject+27346

« previous php.notes (#40277) next »