note 37181 rejected from function.fprintf by pollita
| From: | pollita@php.net | Date: | Thu, 06 Nov 2003 04:17:14 +0000 |
| Subject: | note 37181 rejected from function.fprintf by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59970@lists.php.net to get a copy of this message | ||
Note Submitter: phetta@hotbrev.com
----
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 ;)