php7实例化类有对象有两种方法

php7实例化类有对象有两种方法,下面给介绍具体两种方法php

class Person{
public $a="96net.com.cn";
public function eat(){
echo 'xxxx';
}php7

ide

1,NEW 关键词实例化对象对象

$xm= new Person();
或者
$xm= new Person;字符串

2, 类名字符串,把类名赋值给变量it

$strs='Person';io

$xm= new $strs();function

相关文章
相关标签/搜索