NYCPHP Meetup

NYPHP.org

[nycphp-talk] Setting up PHP 4 OOP to work in PHP 5 environment

csnyder chsnyder at gmail.com
Thu Feb 24 08:59:02 EST 2005


On Thu, 24 Feb 2005 08:11:15 -0500, Randal Rust
<rrust at r2communications.com> wrote:
> I have a nice little codebase that I have written in PHP 4 OOP. I am
> very leary that my host will someday switch to PHP 5, and although
> backwards compatability may be turned on (if it can be), I am still
> leary that my objects will fail upon instantiation.

In general PHP4 OOP is forwards compatible with PHP5. 5 will still
call your Emloyer() method as the constructor, for instance, even
though it prefers __construct().

>         function Employer(){
>                 $this->db =& new DB;
>                 $this->display =& new Display;
>                 $this->validator =& new Validator;
>                 $this->db=$this->db->conn;
>                 }

Out of curiousity, why are you assigning by reference ( =& ) when
creating the new objects?
Is it because DB, Display, and Validator implement a singleton pattern?



More information about the talk mailing list