时间:2021-07-01 10:21:17 帮助过:18人阅读
class myName{
function __construct($myName){ //连续两个下划线
echo ("我的名字是:$myName
");
}
}
$name1 = new myName("小猫");
$name2 = new myName("小狗");
$name3 = new myName("小马");
?>
与之比较的是:
class myName{
function construct($myName){
echo ("我的名字是:$myName
");
}
}
$name1 = new myName("小猫");
$name2 = new myName("小狗");
$name3 = new myName("小马");
?>
http://www.bkjia.com/PHPjc/632487.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/632487.htmlTechArticle__construct 构造函数 类在被实例化时就会执行. construct 自定义的函数或方法. ?php class myName{ function __con str uct($myName){ //连续两个下划线 echo (我...