<?php
class testClass{
private $a,$b;
public function _construct($c,$d){
$this->a=$c+99;
$this->b=$d*99;
}
public function output(){
echo 'the value of $a is '.$this->a.'<br/>';
echo 'the value of $b is '.$this->b.'<br/>';
}
}
$t=new testClass(88,44);
$t->output();
?>原本想输出的a和b的值分别是初始化过的,结果输出是空
class testClass{
private $a,$b;
public function _construct($c,$d){
$this->a=$c+99;
$this->b=$d*99;
}
public function output(){
echo 'the value of $a is '.$this->a.'<br/>';
echo 'the value of $b is '.$this->b.'<br/>';
}
}
$t=new testClass(88,44);
$t->output();
?>原本想输出的a和b的值分别是初始化过的,结果输出是空
class testClass{
private $a,$b;
public function __construct($c,$d){
$this->a=$c+99;
$this->b=$d*99;
}
public function output(){
echo 'the value of $a is '.$this->a.' <br/>';
echo 'the value of $b is '.$this->b.' <br/>';
}
}
$t=new testClass(88,44);
$t->output();
这样就对了