isset PHP isset($ _ GET ['something'])吗? $ _GET ['something']:'' [英] isset PHP isset($_GET['something']) ? $_GET['something'] : ''

查看:92
本文介绍了isset PHP isset($ _ GET ['something'])吗? $ _GET ['something']:''的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望扩展自己的PHP知识,但是遇到了一些不确定的东西,甚至不确定如何搜索.我正在查看php.net isset代码,并且看到了isset($_GET['something']) ? $_GET['something'] : ''

I am looking to expand on my PHP knowledge, and I came across something I am not sure what it is or how to even search for it. I am looking at php.net isset code, and I see isset($_GET['something']) ? $_GET['something'] : ''

我理解正常的isset操作,例如if(isset($_GET['something']){ If something is exists, then it is set and we will do something },但我不理解?,再次重复get,:或''.有人可以帮我解决这个问题,或者至少将我指向正确的方向吗?

I understand normal isset operations, such as if(isset($_GET['something']){ If something is exists, then it is set and we will do something } but I don't understand the ?, repeating the get again, the : or the ''. Can someone help break this down for me or at least point me in the right direction?

推荐答案

通常称为简写"或表示

if(isset($_GET['something'])) {
    $test = $_GET['something'];
} else {
    $test = '';
}

要分解它:

$test = ... // assign variable
isset(...) // test
? ... // if test is true, do ... (equivalent to if)
: ... // otherwise... (equivalent to else)

或者...

// test --v
if(isset(...)) { // if test is true, do ... (equivalent to ?)
    $test = // assign variable
} else { // otherwise... (equivalent to :)

这篇关于isset PHP isset($ _ GET ['something'])吗? $ _GET ['something']:''的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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