Blogger Information
Blog 48
fans 0
comment 0
visits 36362
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
类的声名与实例化-2018.09.03
雨天的博客
Original
587 people have browsed it

实例

<?php
/**
 * 类的声名与实例化
 * 1.类的声名:class
 * 2.对象实例化:new
 * 3.对象成员的访问:->
 */
class Person
{

}
$person = new Person();//实例化对象
//给对象增加属性
$person->name = '小明';
$person->getName = function () {
    return '对象方法';
};
echo $person->name,'<br>';
//call_user_func 调用对象方法
echo call_user_func($person->getName);

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!