note 93197 added to function.echo
| From: | Anonymous at osu1 dot php dot net | Date: | Thu, 27 Aug 2009 22:02:26 +0000 |
| Subject: | note 93197 added to function.echo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159954@lists.php.net to get a copy of this message | ||
This will not give the output expected.
<?php
class String
{
public static function Format()
{
$argc = func_num_args();
$argv = func_get_args();
for ($arg_n = 0; $arg_n < $argc; $arg_n++)
{
$argv[0] = str_replace("\{$arg_n\}", $argv[$arg_n + 1], $argv[0]);
}
return $argv[0];
}
}
echo String::Format("My name is {0} and I am {1} years old", "Thomas", 18);
?>
This works, however:
$argv[0] = str_replace('{' . $arg_n . '}', $argv[$arg_n + 1], $argv[0]);
----
Server IP: 195.184.96.15
Probable Submitter: 212.242.113.145
----
Manual Page -- http://www.php.net/manual/en/function.echo.php
Edit -- https://master.php.net/note/edit/93197
Del: integrated -- https://master.php.net/note/delete/93197/integrated
Del: useless -- https://master.php.net/note/delete/93197/useless
Del: bad code -- https://master.php.net/note/delete/93197/bad+code
Del: spam -- https://master.php.net/note/delete/93197/spam
Del: non-english -- https://master.php.net/note/delete/93197/non-english
Del: in docs -- https://master.php.net/note/delete/93197/in+docs
Del: other reasons-- https://master.php.net/note/delete/93197
Reject -- https://master.php.net/note/reject/93197
Search -- https://master.php.net/manage/user-notes.php