PHP基础14:$_REQUEST

时间:2021-11-23 19:39:08
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
        姓名:<input type="text" name="name"><br>
        <input type="submit" value="提交">
    </form>
    <hr>
</body>
</html>
<?php
    echo "当前的文件路径为";
    echo $_SERVER['PHP_SELF'];
    echo "<hr>";
?>
<?php
    $name = $_REQUEST['name'];
    echo $name;
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
        Name: <input type="text" name="fname">
        <input type="submit">
    </form>

    <?php
        $name = $_POST['fname'];
        echo $name;
    ?>
</body>
</html>