|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-04-25 10:52 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 15:00:01 2025 UTC |
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.