NYCPHP Meetup

NYPHP.org

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

Randal Rust rrust at r2communications.com
Thu Feb 24 08:11:15 EST 2005


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.

I have three classes that I use on every page for the following 
functionality:

- connecting to the database (class_db.php)
- controlling the display of the page (class_display.php)
- validating user input (class_validator.php)

In all of my other classes, I use a constructor to instantiate the above 
classes so that I can use their methods and properties.

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

	//properties

	//methods

	}

I am really still new to the whole OOP thing, but I am learning. I 
definitely see the benefits of it, but I want to make sure that what I 
am describing above will not break in PHP 5. I have a second machine at 
home that I am going to install Apache and PHP 5 on this weekend, but I 
thought I would ask for some feedback first.

TIA.

-- 
Randal Rust

R.Squared Communications
http://www.r2communications.com
Digital Design for Bricks-and-Mortar Businesses




More information about the talk mailing list