From:             timo dot hummel at 4fb dot de
Operating system: n/a
PHP version:      5.0.4
PHP Bug Type:     Feature/Change Request
Bug description:  Overloading builtin functions

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 bug report at http://bugs.php.net/?id=32790&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32790&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32790&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32790&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32790&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32790&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32790&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32790&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32790&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32790&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32790&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32790&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32790&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32790&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32790&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32790&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32790&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32790&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32790&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32790&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32790&r=mysqlcfg

Reply via email to