php基础语法练习
验证可变变量

可变变量即为$$
此处echo $$txt,由于$txt=username $username=gjl也就等同于执行echo $username
最终执行结果就会变成gjl,其它部分代码为做拼接的尝试
<!D<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
$username="psl";
$txt="username";
echo $$txt."<br>";
echo $$txt." "."love eating niuniu<br>";
echo "psl ai chi niuniu<br>";
define ("username3","pslnnzz");
echo username3."<br>";
var_dump($$txt);
echo -$txt;
?>
</body>
</html>
学生成绩评级


使用form表单以及$n=$_POST['gg'];进行传参
if else实现判断
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="" method="post">学生成绩
<input type="text" name="gg">
<button type="submit">submit</button>
</form>
<?php
@$n=$_POST['gg'];
if($n==null){
}else{
if($n>0 && $n<=30){
echo "出院";
}else if($n>30 && $n<=60){
echo "keep hardworking";
}else if($n>60 && $n<=80){
echo "pretty good";
}else if($n>80 && $n<=100){
echo "毕业";
}else{
echo "wrong,retry";
}
}
?>
</body>
</html>
99乘法表

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
echo "<table border=1px>";
for($i=1;$i<10;$i++){
echo "<tr>";
for($j=1;$j<=$i;$j++){
echo "<td>"."{$j}"."*"."{$i}"."="."{$i}"*"{$j}"."</td>";
}
}
echo "</table>"
?>
</body>
</html>
3058

被折叠的 条评论
为什么被折叠?



