Re: Property setter and getter in PHP5

From: Date: Sun, 20 Jul 2003 17:14:44 +0000
Subject: Re: Property setter and getter in PHP5
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-3518@lists.php.net to get a copy of this message
Hi John I knew __get and __set available, but i want to told C# like syntax is a nice and clear syntax if available in php5 , so we dont need to check property name and then set value . "John Lim" <jlim@natsoft.com.my> wrote in message news:20030720163649.50501.qmail@pb1.pair.com... > Hi Masoud, > > It's already available. See > > > http://www.phppatterns.com/index.php/article/articleview/28/1/2/ > > "Masoud" <masoud@iranphp.net> wrote in message > news:20030720155214.18238.qmail@pb1.pair.com... > > It's just a suggestion to have a syntax like this in PHP5! > > > > A property is similar to a field (a member variable), with the exception > > that there is a getter and a setter > > method, as follows : > > > > public class Car > > { > > private string make; > > public string Make > > { > > get { return make; } > > set { make = value; } > > } > > } > > > > Car c = new Car( ); > > c.Make = "Acura"; // use setter > > String s = c.Make; // use getter > > > > above example is a simple C# example in NET Framework Essentials. > > > > > > Masoud > > > > > >

« previous php.internals (#3518) next »