<?php
/* Declaration of a class
* 1. What are you developing , Decide what class to write
* 2. Member of a class 1 Must belong to this class
* [ Modifies the keyword of the class ] class The name of the class {
* Member properties:
* Member methods:
* }
* 3. When a member property is declared in a class, it must be preceded by a modifier , Use when in doubt which word to use var or public
* 1 Save only 1 Class, file name contains the class name, file: class name .class.php
* Class name:
* Variables: aaaBbbCcc
* Function: aaaBbbCcc
* Constants: AAABBBCCC
* The name of the class: AaaBbbCcc
* 4. Class member properties, if you create more than one object, each object has a different property value, do not directly give the initial value, after the creation of the object to the value
*
*
* Instantiate objects through classes
* 1. Using the new new 1 Object, plus the class name, is the object of which class is created
* $ Object reference =new The name of the class ;
* 2. As long as there is 1 a new The keyword is create 1 Object, create 1 The objects are allocated in memory 1 A space
*
* Only objects contain storage space
*
* Object action
*
* Object allocation in memory
*
* Use of objects
* Members of an object must be accessed by reference to the object
* object -> Members of the
*
* object -> Member attribute
* object -> Members of the method
*
*
*
*/
// Declaration of a class ( The telephone class )
class Phone{
// Declaration attributes
var $pinPai;
var $color;
var $batteryCapacity;
var $screenSize;
// Members of the method
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
$p1=new Person;
$p2=new Person;
$p3=new Person;
// Access the members of the object
$p1->name="zhangsan";
echo $p1->name;
?>