时间:2021-07-01 10:21:17 帮助过:16人阅读
输出结果:
function exam($var1){
$var1++;
echo "In Exam:" . $var1 . "
";
}
$var1 = 1;
echo $var1 . "
";
exam($var1);
echo $var1 . "
";
?>
-------------------------------------------------------------------------------
输出结果:
function exam( &$var1){
$var1++;
echo "In Exam:" . $var1 . "
";
}
$var1 = 1;
echo $var1 . "
";
exam($var1);
echo $var1 . "
";
?>
-------------------------------------------------------------------------------
输出结果:
function values($price, $tax=""){
$price += $prive * $tax;
echo "Total Price:" . $price . "
";
}
values(100, 0.25);
values(100);
输出结果:
class Obj{
public $name;
public $age;
public $gander;
public function __construct($name, $age, $gander){
$this->name = $name;
$this->age = $age;
$this->gander = $gander;
}
public function show_info(){
echo $this->name . " " . $this->age . " " . $this->gander . "
";
}
}
function grow($obj){
$obj->age++;
}
function test(){
$obj = new Obj("Mr. zhan", "12", "male");
$obj->show_info();
grow($obj);
$obj->show_info();
grow($obj);
$obj->show_info();
}
test();
?>
-------------------------------------------------------------------------------