函數和類來實現,包括計數,字符串連接,函數返 回結果,數字加法運算,數字乘法運算,數字大小排序等通過函數來實現的例子
<?php教程
function small_numbers()
{
return array (0, 1, 2);
}
list ($zero, $one, $two) = small_numbers();
?>
函數引用
<?php
function &returns_reference()
{
return $someref;
}
$newref =& returns_reference();
?>
相加減
<?php
function foo()
{
$numargs = func_num_args();
echo "number of arguments: $numargs<br />n";
if ($numargs >= 2) {
echo "second argument is: " . func_get_arg(1) . "<br />n";
}
$arg_list = func_get_args();
for ($i = 0; $i < $numargs; $i++) {
echo "argument $i is: " . $arg_list[$i] . "<br />n";
}
}
foo(1, 2, 3);
?>