there is no declaration of the return value of a function
it's always something like 'mixed'
manual chapter
you cannot overload global-scope functions
req.php:
Code: Select all
<?php function test() { ... }?>
index.php:
Code: Select all
<?php require('req.php');
function test() { ... }
test();
?>
will lead to
PHP Fatal error: Cannot redeclare test() (previously declared in <blablabla>:<line>) in <blablabla> on line <line>
even function test($param) {...} fails.
But you can overload methods of objects
there are some useful
user contributed notes on this topic in the manual
Code: Select all
<html><body><?php class cbase
{
function cbase() { print('base constructed<br>'); }
function doSomething() { print('base function<br>'); }
}
class cderived extends cbase
{
function cderived() { print('derived constructed<br>'); }
function doSomething() { print('derived function<br>'); }
}
$cd = new cderived;
$cd->doSomething();
?></body></html>
leads to
derived constructed
derived function
if you take out 'function cderived() {..}' the output is
base constructed
derived function