Home >Backend Development >PHP Tutorial >理解$val = !empty($_GET[$str]) ? $_GET[$str] : null;

理解$val = !empty($_GET[$str]) ? $_GET[$str] : null;

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:24:271228browse

如何理解$val = !empty($_GET[$str]) ? $_GET[$str] : null;这句话


回复讨论(解决方案)

它就是if else 的变形,下面这样应该能理解了吧

if(!empty($_GET[$str]))   $val= $_GET[$str];else   $val = null;

三元表达式
$val = !empty($_GET[$str]) ? $_GET[$str] : null;
如果$_GET[$str]非空(不为空值),那么$val=$_GET[$str];
反之$val=null;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:CURL 设置出错Next article:求一算法!!