Beware of Differences PHP4 & PHP5

In PHP4, constructor has same name as class:

class Welcome {
function Welcome() {

}}

In PHP5, constructor is always __construct():

class Welcome {
function __construct() {
}}

In PHP4, when you extend you call parent constructor like:

class Welcome extends Parent{

function Welcome() {
parent::Parent();
}}

In PHP 5, you extend like:

class Welcome extends Parent{

function __construct() {
parent::__construct();
}

I am using PHP5 but I was using PHP4 to extend my classes. Lovely!




Related posts:

  1. Facebook app in 10 minutes
  2. Padding a String with Zeros in Java

Leave a Reply