
你想问啥。
$a =& new A(10);
这句多此一举, 这么写一样$a = new A(10);
想值传递或者说复制对象? 这么写 $a = new A(10);
$b = clone $a;
<php
class test{
private $arr;
function __construct(){
$arr = array(
'num' => '10001', // 学号
'name' => 'test', // 姓名
'class' => '班级' // 班级
);
}
function _get(){
return $this->arr;
}
}
$test = new test();
echo '<pre>';
print_r($test->_get());
直接在实例化 class 类的时候传参数;
$a = new Class( $param1, $param2 );
public function __construct( $a, $b ) {
echo $a;
echo $b; // 可以这样在构造方法中输出来就看到了
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)