复制代码 代码如下:
/* 类的声明
* 1.你要开发的是什么,确定写什么类
* 2.类中的成员一定要属于这个类
* [修饰类的关键字] class 类名{
* 成员属性:
* 成员方法:
* }
* 3.在类中声明成员属性时,前面必须有修饰词,当不确定使用哪个词时,使用var或public
* 一个文件只保存一个类,文件名中包含类名,文件:类名.class.php
* 类名的写法:
* 变量:aaaBbbCcc
* 函数:aaaBbbCcc
* 常量:AAABBBCCC
* 类名:AaaBbbCcc
* 4.类中的成员属性,如果创建多个对象时,每个对象有不同的属性值时,不要直接给初值,在创建好对象之后再给值
*
*
* 通过类来实例化对象
* 1.使用的是new新建一个对象,加上类名,就是创建哪个类的对象
* $对象引用=new 类名;
* 2.只要有一个new 关键字就是创建一个对象,创建一个对象就是在内存中分配了一个空间
*
* 只有对象才在内存有存储空间
*
* 对象的作用
*
* 对象在内存中的分配
*
* 对象的使用
* 对象中的成员必须通过对象的引用来访问
* 对象->成员
*
* 对象->成员属性
* 对象->成员方法
*
*
*
*/
//类的声明(电话类)
class Phone{
//声明属性
var $pinPai;
var $color;
var $batteryCapacity;
var $screenSize;
//成员方法
function call(){
}
function message(){
}
function playMusic(){
}
function photo(){
}
}
//类的实例化
class Person{
var $name;
var $age;
var $sex;
function say(){
}
function eat(){
}
function run(){
}
}
//实例化
$p1=new Person;
$p2=new Person;
$p3=new Person;
//访问对象的成员
$p1->name="zhangsan";
echo $p1->name;
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
