NYCPHP Meetup

NYPHP.org

[nycphp-talk] __get __set methods..

Alex C alexchan.1976 at gmail.com
Tue Apr 19 20:21:53 EDT 2005


I am trying to use __set and __get magic methods to access private
properties of a class. However , I keep on getting this error. I am
using PHP 5.03..

Fatal error: Cannot access private property Runner::$programName 


I am not sure what I am doing wrong..  thanks in advance

my class looks as follows.
---

  class Runner  {
 	private $programName;
	private $programDate; 
	private $raceNumber;
	private $runnerNumber;

 	private $scratchedStatus;
	
 	public function __get($property){
 		return $this->$property;
 	}
 	
 	public function __set($property, $value){
 		$this->$property = $value;
 	}
}



More information about the talk mailing list