菜单

php函数

2014-11-07 - Developer

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>二维数组</title>
</head>
<body>
<?php
$arr[0][0]=10;
$arr[0][1]=22;
$arr[1][0]=1E+05;
$arr[1][1]=”这不是来了”;
for($i=0;$i<count($arr);$i++){
for($k=0;$k<count($arr[$i]);$k++){
$arr1=each($arr[$i]);
echo “$arr1[value]<br />”;
}
}
//php向函数传递参数
function totalneedtopay($days,$roomprice){
$totalcost=$days*$roomprice;
echo “需要支付的总价:$totalcost”.”元<br />”;
}

$rentdays=3;
$roomprice=168;
totalneedtopay($rentdays, $roomprice);
totalneedtopay(5,198);
//php向函数中传递参数引用
$fee=300;
$serviceprice=50;
function totalfee(&$fee,$serviceprice){
$fee=$fee+$serviceprice;
echo “需要支付的总价:$fee”.”元<br />”;
}
totalfee($fee, $serviceprice);
totalfee($fee, $serviceprice);
//php从函数中返回值
function totalneedtopay1($days1, $roomprice1){
return $days1*$roomprice1;
}
$rentdays1=3;
$roomprice1=168;
echo totalneedtopay1($rentdays1, $roomprice1);
?>
</body>
</html>

转载请注明: 转载自—艾瑞可erik

本文链接地址: http://erik.xyz/317.html

标签:,

发表评论