摘要:本文主要向大家介绍了PHP语言 18.4.20,通过具体的内容向大家展示,希望对大家学习php语言有所帮助。
本文主要向大家介绍了PHP语言 18.4.20,通过具体的内容向大家展示,希望对大家学习php语言有所帮助。
数组求和比大小
<meta charset="utf-8">
<form action="mysql.php" method="get">
数组a:<input type="text" name="a">
<br>
<br>
数组b:<input type="text" name="b">
<br>
<br>
<input type="submit" name="提交">
<input type="reset" name="充值">
</form>
<?php
$a = $_GET["a"];
$b = $_GET["b"];
$targetA = explode(",", $a);
$targetB = explode(",", $b);
$sumA = 0;
$sumB = 0;
for ($i=0; $i < count($targetA); $i++) {
$sumA += $targetA[$i];
}
for ($i=0; $i < count($targetB); $i++) {
$sumB += $targetB[$i];
}
if ($sumA > $sumB) {
echo "a > b";
}elseif($sumA < $sumB){
echo "a < b";
}?>
<meta charset="utf-8">
<?php
$information = array(
array(1,'Tom','male','86929902'),
array(2,'Lily','female','86929903'),
array(3,'Rose','female','86929901'),
array(4,'Jason','female','86929904')
);
echo '<table border="1">';
echo "<tr>";echo "<th>学号</th>";echo "<th>姓名</th>";echo "<th>性别</th>";echo "<th>电话</th>";echo "</tr>";for ($i=0; $i < count($information); $i++) {
echo "<tr>";
for ($j=0; $j < 4; $j++) {
echo "<td>";
echo $information[$i][$j];
echo "</td>";
}
echo "</tr>";
}echo '</table>';
?>
<meta charset="utf-8">
<?phpclass Student{
public $id;
public $name;
public $gender;
public $phone;
}
$tom = new Student();
$tom -> id = 1;
$tom -> name = 'Tom';
$tom -> gender = 'male';
$tom -> phone = '86929902';
$lily = new Student();
$lily -> id = 2;
$lily -> name = 'Lily';
$lily -> gender = 'female';
$lily -> phone = '86929903';
$rose = new Student();
$rose -> id = 3;
$rose -> name = 'Rose';
$rose -> gender = 'female';
$rose -> phone = '86929901';
$jason = new Student();
$jason -> id = 4;
$jason -> name = 'Jason';
$jason -> gender = 'male';
$jason -> phone = '86929904';
$table = array($tom,$lily,$rose,$jason);
echo '<table border="1">';
echo "<tr>";echo "<th>学号</th>";echo "<th>姓名</th>";echo "<th>性别</th>";echo "<th>电话</th>";echo "</tr>";
for ($i=0; $i < count($table); $i++) {
echo "<tr>";
echo "<td>";
echo $table[$i] -> id;
echo "</td>";
echo "<td>";
echo $table[$i] -> name;
echo "</td>";
echo "<td>";
echo $table[$i] -> gender;
echo "</td>";
echo "<td>";
echo $table[$i] -> phone;
echo "</td>";
echo "</tr>";
}
echo '</table>';?>
以上就介绍了PHP的相关知识,希望对PHP有兴趣的朋友有所帮助。了解更多内容,请关注职坐标编程语言PHP频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号