Copy CodeThe code is as follows:
/* Declaration of Class
* 1. What are you going to develop, determine what class to write
* 2. Members of the class must belong to this class
* [modifier class's Keywords] class class name {
* Member Properties:
* Member Method:
* }
* 3. When declaring member properties in a class, there must be a modifier in front of it, using VAR or public when unsure which word to use
* One file holds only one class, and the file name contains the class name, the document: class name. class.php
* The notation of the class name:
* Variable: AAABBBCCC
* Function: AAABBBCCC
* Constant: AAABBBCCC
* Class Name: AAABBBCCC
* 4. member properties in the class, if you create multiple objects, each object has a different property value, do not give the initial value directly, after creating the good object and then give the values
*
*
* Instantiate objects by class
* 1. Use new to create a new object, plus the class name, which is the object that created the class
* $ object reference =new class name;
* 2. As long as there is a new keyword is to create an object, create an object is to allocate a space in memory
*
* Only objects have storage space inside
*
* Role of the object
*
* Allocation of objects in memory
*
* Use of objects
* Members in an object must be accessed by reference to the object
* Objects, Members
*
* Object--member properties
* Object--member method
*
*
*
*/
Declaration of class (phone class)
Class phone{
declaring properties
var $pinPai;
var $color;
var $batteryCapacity;
var $screenSize;
Member Methods
function call () {
}
Function message () {
}
function Playmusic () {
}
function photo () {
}
}
Instantiation of a class
Class person{
var $name;
var $age;
var $sex;
function say () {
}
Function Eat () {
}
function Run () {
}
}
Instantiation of
$p 1=new person;
$p 2=new person;
$p 3=new person;
Accessing the members of an object
$p 1->name= "Zhangsan";
Echo $p 1->name;
?>
http://www.bkjia.com/PHPjc/323522.html www.bkjia.com true http://www.bkjia.com/PHPjc/323522.html techarticle Copy the code as follows:? Declaration of the PHP/* class * 1. What you want to develop, determine what class to write * 2. Members of the class must belong to this class * [modifier class keyword] class name {...