Re: Property setter and getter in PHP5

From: Date: Sun, 20 Jul 2003 16:28:46 +0000
Subject: Re: Property setter and getter in PHP5
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-3516@lists.php.net to get a copy of this message
Hello Masoud, Sunday, July 20, 2003, 5:52:12 PM, you wrote: M> It's just a suggestion to have a syntax like this in PHP5! M> A property is similar to a field (a member variable), with the exception M> that there is a getter and a setter M> method, as follows : M> public class Car M> { M> private string make; M> public string Make M> { M> get { return make; } M> set { make = value; } M> } M> } M> Car c = new Car( ); M> c.Make = "Acura"; // use setter M> String s = c.Make; // use getter M> above example is a simple C# example in NET Framework Essentials. Other languages support this too. Have a look a __get and __set. -- Best regards, Marcus mailto:helly@php.net

« previous php.internals (#3516) next »