Welcome Guest, Not a member yet? Register   Sign In
newbie class constructor question on the PHP 4 vs PHP 5 syntax
#1

[eluser]Doug Lerner[/eluser]
In the documentation it points out that this syntax is used to define a construction in PHP 4:

Code:
class Blog extends Controller {

       function Blog()
       {
            parent::Controller();
       }
}

while this syntax is used in PHP 5:

Code:
class Blog extends Controller {

       function _construct()
       {
            parent::Controller();
       }
}

In the rest of the documentation pages the PHP 4 syntax seems to be used.

My question is, if my site is using PHP 5 does it make any difference at all which syntax I actually use, or are they equivalent in PHP 5?

Thanks,

doug
#2

[eluser]Michael Wales[/eluser]
They are the same in PHP5 - the PHP4 syntax is used throughout the documentation to promote portability.
#3

[eluser]Seppo[/eluser]
If you are running PHP 5, it will use __construct if is defined. If it isn't, then it will use the PHP 4 constructor. So if you use the PHP 4 syntax and you don't define a PHP 5 constructor, it will work on both PHP 4 and 5.




Theme © iAndrew 2016 - Forum software by © MyBB