alain dhaene wrote:
Is it possible to have more constructors in the same class?
As I understand it, all methods in PHP follow the general functions rule,
which is that you can't redeclare a function. Unlike Java, where a method's
signature includes the arguments and the return type besides the name
itself, in PHP the "signature" is only the method's name.
However, you can "overload" a function by stating optional arguments, which
are defined in fuction definition, but can be avoided when calling the
function/method.
In your example, the constructor could be:
person($name, $age = NULL)
and your two example calls would work.
Berislav