note 88221 deleted from function.func-get-args by thiago
| From: | thiago@php.net | Date: | Fri, 06 Feb 2009 15:45:38 +0000 |
| Subject: | note 88221 deleted from function.func-get-args by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150309@lists.php.net to get a copy of this message | ||
Note Submitter: Andrey
----
Instead of
<?php
put2log(sprintf('Error %u occured, try use %s.', 123, 'your head'));
?>
You can use this
<?php
function put2log($msg /*, ...*/)
{
$args = func_get_args();
$msg = eval('return sprintf($args['. implode('], $args[', array_keys($args))
.']);');
write_to_my_log($msg);
}
?>
And now you can call
<?php
put2log('Error %u occured, try use %s.', 123, 'your head');
?>