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   26 mountain parks all over Ji'nan   The young man insisted on 10 years' ...   Do you remember those "made in Ji'na...   Ji'nan's Daming Lake scenic area is ...   Ji'nan free Scenic Area
rand   PHP methods to prevent repeated subm...   Use of get, request, and post in PHP   The use of PHP real multithreading   PHP reads all the same types of file...   PHP garbled problem, UTF-8 (garbled)...
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