NYCPHP Meetup

NYPHP.org

[nycphp-talk] Accessing Properties in PHP OOP

randal rust rrust at r2communications.com
Thu Aug 26 09:53:15 EDT 2004


Scott Mattocks wrote:

> You need to make display and validator a member of the client class. 
> Then you client class would look like this.
> 
> class Client {
>     var $display;
>     var $validator;
>     var $conn;
>     var $clientNameEM;
>     var $clientName;
> 
>     function Client() {
>         $this->display   =& new Display;
>     $this->validator =& new Validator;
>     $this->conn      =& new Conn; //Don't know where this comes from.
>     }

OK, that makes sense. But how is it different, or better than what I'm 
doing now? On the surface, it appears that my current method may break 
in PHP 5. I'm currently using different versions of PHP 4.2+, but want 
to code it so that I won't have too much to change whenever I bump up to 5.

FYI, $conn is a call to my database connection.

And, just so I make sure I understand, each of my individual methods 
within client, which need to access class_display and class_validator, 
would need to include...

$this->display =& new Display
$this->validator =& new Validator

...right?

-- 
Randal Rust

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




More information about the talk mailing list