> >

Re: PHP class class Usage Summary

time:13-07-05 forum:PHP tools and code
  Three, class properties:
there are two ways to assign or value properties of classes.
1, using the common domain public keyword.
2, using __set () and __get () to assign and value respectively, the former is called a set method (setter) or a modification method (mutator), and the latter is called the access method (accessor) or the acquisition method (getter). It is recommended to use this method: the advantages are:
A and data validation in __set ().
B, easy to unified management properties.
note:
First: __set () and __get () only play a role in private properties. For attributes defined by public, they are two lazy.
class test{
protected $a=9, $b=2, $c;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

prev:An introductory PHP Class article next:To save the sick child, the 63 year old ...
post comments
Notice



Approved   Brachless college students play game...   The most inspirational live street "...   Ji'nan old shoemaker has made more t...   Ji'nan auxiliary police "storm" Engl...   Australian 16 year old girl, driving...
rand   Generating HTML static pages with PH...   PHP reads the content of the MySQL d...   PHP time function date () solves the...   Using iconv to transform UTF-8 Chine...   The strftime () function converts mo...
ads

other

Because all the contents of this site are reproduced from other media, the intention is to provide free services to the public, but it does not mean that this site agrees with its views, and can not be responsible for the authenticity of its verification, such as the copyright unit or individual of the manuscript does not want to publish on this site, please Contact me, I will immediately remove it, thank you. Contact: atseashawk@163.com