Non del tutto corretto. In PHP4 come costruttore veniva utilizzato il metodo con lo stesso nome della classe.Originariamente inviato da andreamk
In php il costruttore si definisce con
Non con il nome della classeCodice PHP:function __construct() { }
Il PHP 5 supporta lo stesso comportamento per compatibilità all'indietro:
For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, it will search for the old-style constructor function, by the name of the class.

Rispondi quotando