是什么$ _GET ['关键']返回如果键不? [英] What does $_GET['key'] return if the key is not set?

查看:141
本文介绍了是什么$ _GET ['关键']返回如果键不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是什么$ _GET返回时,不设置索引? (找不到PHP手册约$ _GET任何东西。)

我写了这个检查,如果$ _GET ['身份证']使用isset - 如果不是这样,设置的$ id为false:

 < PHP的$ id =(使用isset($ _ GET ['身份证']))? $ _GET ['身份证']:假>


解决方案

$ _ GET只是一个普通的数组,所以它的行为完全一样的任何其他数组。

这意味着,它将返回NULL的变量,当你调用一个不存在的指数提高未定义指数的通知。

您需要了解与$ _GET是唯一包含不安全的(用户可修改)的数据

What does $_GET return when the index is not set? (Couldn't find anything in php manual about $_GET.)

I wrote this to check, if the $_GET['id'] isset - and if it is not, set $id to false:

<?php $id = (isset($_GET['id'])) ? $_GET['id'] : false ?>

解决方案

$_GET is just an ordinary array, so it behaves exactly the same as any other array.

This means, it will return NULL to the variable and raise the "undefined index" notice when you call a non-existing index.

The only thing you need to be aware of with $_GET is that is contains unsafe (user-modifiable) data

这篇关于是什么$ _GET ['关键']返回如果键不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆