时间:2021-07-01 10:21:17 帮助过:5人阅读
输出结果:
<?php
function exam($var1){
$var1++;
echo "In Exam:" . $var1 . "<br />";
}
$var1 = 1;
echo $var1 . "<br />";
exam($var1);
echo $var1 . "<br />";
?>
-------------------------------------------------------------------------------
输出结果:
<?php
function exam( &$var1){
$var1++;
echo "In Exam:" . $var1 . "<br />";
}
$var1 = 1;
echo $var1 . "<br />";
exam($var1);
echo $var1 . "<br />";
?>
-------------------------------------------------------------------------------
输出结果:
function values($price, $tax=""){
$price += $prive * $tax;
echo "Total Price:" . $price . "<br />";
}
values(100, 0.25);
values(100);
输出结果:
<?php
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 . "<br />";
}
}
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();
?>
-------------------------------------------------------------------------------