Property setter and getter in PHP5
| From: | Masoud | Date: | Sun, 20 Jul 2003 15:52:12 +0000 |
| Subject: | Property setter and getter in PHP5 | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-3515@lists.php.net to get a copy of this message | ||
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