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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:24:27
Original
1229 people have browsed it

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


回复讨论(解决方案)

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

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template