NYCPHP Meetup

NYPHP.org

[nycphp-talk] Accessing Properties in PHP OOP

Scott Mattocks scott at crisscott.com
Thu Aug 26 09:37:10 EDT 2004


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.
     }

     function clientNameCheck($value){

         $test = $this->validator->validateMixed($value);
         if(!$test){
             $this->display->errors = true;
             $this->clientNameEM = '<p class="error">ERROR: Client name 
is not valid.</p>';
             return false;
             }
         }
     //begin add method
     function addClient(){

         //validate user input

         $this->clientNameCheck($this->clientName);
         }
     //end add method
     }

Scott Mattocks



More information about the talk mailing list