Blogger Information
Blog 40
fans 0
comment 0
visits 37602
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP学习总结(3)GET与POST——2019年9月20号20:00分
虎子爸爸
Original
1017 people have browsed it

0920-2.png

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>get与post</title>
</head>
<body>
    <h3>GET传值</h3>
    <a href="?name=朱老师">点击这里进行get地址栏传值</a>
    <p>
        这里输出值:<?php 
        if(isset($_GET['name'])){
            echo "地址栏传的值为---".$_GET['name']; 
        }else{
            echo "地址栏传还没有传值,点击上面的链接"; 
        }
        
        ?>
    </p>
    <h3>post传值--一般是表单传值</h3>
    <p>
        
        <form action="#" method="post">
        姓名:<input type="text" name="username" value="<?php echo isset($_POST['username']) ? $_POST['username'] : "默认值";
        ?>">
        昵称:<input type="text" name="nickname">
        <button>提交表单</button>
        </form>

        
    </p>
    <p>
        这里输出表单值:
        <?php
        if(isset($_POST['username']) or isset($_POST['nickname'])){
            echo "姓名:".$_POST['username']."  昵称:".$_POST['nickname'];
        }else{
            echo "先输入点内容";
        }
        
        ?>
    </p>
    <p>
        三元运算符:
        <?php
        echo isset($_POST['nickname']) ? $_POST['nickname'] : "这是三元运算符";
        ?>
        </p>


</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post