PHP class class Usage Summary

time:13-07-05 forum:PHP tools and code
  Reloaded from http://www.onexin.net/php-class-class-usage-summary/

1: structure and call (instantiation):

class className{}, call: $obj = new className (); when a class has a constructor, the parameter should also be passed. Such as $obj = new className ($v, $v2...

Two: constructor and destructor:
1, constructor for initialization: use __construct (), with parameters.
2, but destructor can not bring parameters (for performing some operation or function before a class is sold). The destructor is named by __destruct (). At the end of the script execution, the object in memory will be dropped, so no function can be created, but some such as COOKIE should be dropped with this function.
knowledge point: a constructor is also provided in PHP4, but a class method with the same class is used. In PHP5, it is still compatible with this method. When no __construct is included in a class, a method of the same name is found. If found, it is considered a constructor, such as
class test
= var $b;
fun. Ction test () {$this-.gt; b=5;}
function AddAB ($c) {return $this-.gt; B $c;
class employee{
function __construct ()... .
}
class Manager extents Employee{
function __construct () {
parent:: _construct (); }
}
of course can also call other class constructors that have nothing to do with the instance. Just add the class name before __construct (). Such as:
otherClassName:: __construct ();

main family members: properties, methods, constants, static members.
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

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



approved   A rare picture of the old Ji'nan! Th...   The deep mountain women's back husba...   Sichuan Leshan 84 year old Lao Tai a...   Loss of breast and cancer coexistenc...   The "ship man" in the city: the aver...
rand   PHP good verification code   PHP upload file code, suitable for b...   Install.php simple production   The use of UBB in PHP   The difference between engine=innodb...
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