[Php] constructor function with the same name as the class name

java and c ++++ constructor is the class name of the same name, is an earlier version of php, but it seems after php4, will be replaced by __construct, anyway, I php into the pit when he had> = php4 version;

Current version: php5.6, consider the definition of the class Txx

1. When the class is present inside the __construct () and Txx () simultaneously

    Txx () method will be treated as an ordinary class method

2. When the class when there Txx () and undefined __construct (), and the undefined php file namespace

    Txx () will be treated as constructor is used (php but there is a warning, suggesting the future may not be so used)

When there Txx 3. When the class () and undefined __construct (), and defines the namespace file php

    Txx () method will be treated as an ordinary class method

 

Tips: php class names and method names are not case sensitive

If there Sb sb class and the class will be reported ill-defined error while classes exist inside Sb () method and empathy when sb method

Published 35 original articles · won praise 18 · views 370 000 +

Guess you like

Origin blog.csdn.net/TXX_c/article/details/81163508