note 37181 added to function.fprintf
| From: | phetta at hotbrev dot com | Date: | Thu, 06 Nov 2003 01:16:52 +0000 |
| Subject: | note 37181 added to function.fprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59968@lists.php.net to get a copy of this message | ||
If you are coding for php5, but the code might be used on version prior php5; Or you are planning on
using your code for php5 but you dont currently use it. (or for some other reason).
Take a look on this code that provides a wrapper for the function.
<?php
if (!function_exists('fprintf')) {
/**
* @desc Wrapper for php versions prior php5.
* @return int
* @param $handle resource
* @param $format string
*/
function fprintf($handle, $format)
{
$argc = func_num_args();
$argv = func_get_args();
$sprintf = "\$format = sprintf(\"".$format."\"";
for ($i=2; $argc > 2 && $i < $argc; $i++) {
$sprintf .= ", \$argv[$i]";
}
$sprintf .= ");";
eval($sprintf);
return fwrite($handle,$format);
}
}
?>
Why fprintf() hasn't been added until php5 I don't know, as it isn't such advanced
function. My guess is that they just forgot it ;)
----
Manual Page -- http://www.php.net/manual/en/function.fprintf.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37181
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37181&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37181&report=yes
Search -- http://master.php.net/manage/user-notes.php