PHP4 Class – differences from PHP5

by Yang Yang on January 14, 2009

Creating a rather simple custom CMS on my client’s server, everything seems ok until I start testing out some of my ready made proprietary PHP classes. The problem is that I make things in PHP5 and all the classes are in PHP5 format.

Quickly searched and scanned through some old tutorials for PHP4 about creating classes. It’s some radical changes indeed. Just to soothe your possible frustrations when migrating PHP5 classes into a PHP4 platform:

  1. PHP4 classes don’t have scope operators such as private, public or protected.
  2. PHP4 constructional function should be the same name with that of the class. __construction won’t work.
  3. Class variables in PHP4 classes are declared with the keyword ‘var’ rather than private or public.

I thought I might write this down for those who are rewriting PHP5 classes for obsolete implementations of PHP such as PHP4.

Jens Törnell February 10, 2010 at 3:09 am

Thanks! Just what I needed.

John March 9, 2011 at 5:12 pm

Yeah thanks, the __construct() function not working was getting the better of me!

Comments on this entry are closed.

{ 2 trackbacks }

Previous post:

Next post: