I am surprised for why the constructor is called when we have different class and constructor name. Constructor name is starting with small "r"?
class Registration{
function registration(){
echo "Constructor is called.";
}
}
$obj = new Registration();
//$obj->registration();
Outputs: Constructor is called.
Modification: Does this case-insensitive behavior depends on php versions we are using?
php is case-insensitive (sometimes). The following would work as well:
CLASS REGISTRATION {
FUNCTION reGISTration(){
ECHO "constructor is called.";
}
}
$obj = NEW Registration();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With