Content deleted Content added
Citation bot (talk | contribs) Added date. | Use this bot. Report bugs. | Suggested by Dominic3203 | Linked from User:LinguisticMystic/cs/outline | #UCB_webform_linked 417/2277 |
m →Syntax: Serial comma to avoid confusion. |
||
Line 60:
== Syntax ==
* [[Java (programming language)|Java]], [[C++]], [[C Sharp (programming language)|C#]], [[ActionScript]], {{nowrap|[[PHP]] 4}}, and [[MATLAB]] have a naming convention in which constructors have the same name as the class with which they are associated.
* In PHP 5, a recommended name for a constructor is <code>__construct</code>. For backwards compatibility, a method with the same name as the class will be called if <code>__construct</code> method can not be found. Since PHP 5.3.3, this works only for non-namespaced classes.<ref name="php5cpnstructor">[http://www.php.net/manual/en/language.oop5.decon.php Constructors and Destructors], from PHP online documentation</ref>
* In PHP 7, you should always name the constructor as <code>__construct</code>. Methods with the same name as the class will trigger an E_DEPRECATED level error.<ref name="php5cpnstructor">[http://www.php.net/manual/en/language.oop5.decon.php Constructors and Destructors], from PHP online documentation</ref>
|