ID: 32790
Updated by: [EMAIL PROTECTED]
Reported By: timo dot hummel at 4fb dot de
-Status: Open
+Status: Wont fix
Bug Type: Feature/Change Request
Operating System: n/a
PHP Version: 5.0.4
New Comment:
We will not implement this in the core, but you can use the runkit pecl
extension - which has similar features.
Previous Comments:
------------------------------------------------------------------------
[2005-04-21 15:10:49] timo dot hummel at 4fb dot de
Description:
------------
A very helpful and nice feature for PHP would be to overload builtin
functions. As PHP5 now features the functions echo and print are
calling the method __toString if it exists in a class, that feature is
still lacking in many other functions where they may be useful (like
sprintf, printf, just to name a few).
To prevent that PHP developers have to do alot of work and to provide a
general interface, something like the following pseudo code demonstrates
overloading builtin functions:
<?php
function myOwnEcho ()
{
$ts = date("Y-m-d H:i:s");
print ($ts . " ");
$num_args = func_num_args();
for ($i=0; $i < $num_args; $i++)
{
print (func_get_arg($i));
}
}
overload_function("echo", "myOwnEcho");
echo "foo";
?>
Results in:
2004-04-21 15:09:01 foo
I know that echo is a language construct and not a function, it's just
been used because most PHP developers use echo for output.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32790&edit=1