Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Here be dragons .... 1

Status
Not open for further replies.

jpadie

Technical User
Nov 24, 2003
10,094
FR
to all who use php's OO functionality: beware of a nasty trap in php 5.3.3 +

if you have a class in a namespace then you can no longer rely on the php4 method of creating constructors.

this should not matter to those who are not coding for backwards compatible apps since you will, by now, be using proper constructors (and, of course, namespaces are not supported). However it remains a pitfall for people who have not updated their coding style.

e.g.
Code:
namespace myNameSpace;

class myClass{
   
  public function myClass(){
   
      //in previous versions of php this (same name as class) would considered a constructor if there were no __constructor method. 
     // in php 5.3.3 this is treated as a regular method and will need to be called explicitly.
     // so the bottom line is that now, at least, is the time that you should move to proper __construct() methods

  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top