Example:
I want to have two different constructors, and I don’t want to use func_get_arg(), because then it’s invisible what args are possible.
Is it legal to write two of them, like:
class MyClass {
public function __construct() {
// do something
}
public function __construct(array $arg) {
// do something
}
}
?
No, but you can do this:
In PHP, a function can receive any number of arguments, and they don’t have to be defined if you give them a default value. This is how you can ‘fake’ function overloading and allow access to functions with different arguments.