<?php class dog{ var $name; // php 将所有以__(两个下划线)开头的类方法保留为魔术方法。 // 所以在定义类方法时,除了魔术方法,建议不要以__为前缀 // construct 构成;建造 构造函数声明必须是__construct() function __construct($n){ $this->name = $n; } function bark(){ echo $this->name."wang"; } } $mydog = new dog("zhangsan"); $mydog->bark(); ?>
原文链接:https://www.qiquanji.com/post/7483.html
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

微信扫码关注
更新实时通知