zoukankan      html  css  js  c++  java
  • PHP过滤器 filter_has_var() 函数

    定义和用法

    filter_has_var() 函数检查是否存在指定输入类型的变量。

    如果成功则返回 TRUE,如果失败则返回 FALSE。

    语法

    filter_has_var(type, variable)
    第一个参数type(必须):规定要检查的类型,可以检查的类型有INPUT_GET、INPUT_POST、INPUT_COOKIE、INPUT_SERVER、INPUT_ENV
    第二个参数variable(必须):需要检查的变量
     
    例子:
    <?php
        if(!filter_has_var(INPUT_GET, "name")) {
            echo("Input type does not exist");
        }
        else {
            echo("Input type exists");
        }

    地址栏输入链接:localhost://test.php?name=test

    输出结果:
    Input type exists

    使用此函数可以用来检查是否是GET或POST提交以及是否有COOKIE变量存在。

    当然,你也可以使用 isset($_GET["name"]) 进行判断

        // Please note that the function does not check the live array, 
        // it actually checks the content received by php:
        $_GET['name'] = 1;
        echo filter_input(INPUT_GET, 'name') ? 'Yes' : 'No';

    输出结果:

    NO
  • 相关阅读:
    install git on ubuntu
    deploy uwsgi with niginx on ubuntu
    ubuntu下部署solr
    solr relevent project
    20100722
    [Programming Visual C++]Ex05cCScrollView Revisited
    iter_test
    交友类节目
    install scrapy on windows
    20100703
  • 原文地址:https://www.cnblogs.com/ryanzheng/p/8736583.html
Copyright © 2011-2022 走看看