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.