php简单小练习

php基础语法练习

验证可变变量

image-20231020171940617

可变变量即为$$

此处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>

学生成绩评级

image-20231020165722460

image-20231020165752619

使用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乘法表

image-20231020171817961

<!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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值