Home  >  Article  >  Backend Development  >  麻烦大家帮小弟我看下这句代码

麻烦大家帮小弟我看下这句代码

WBOY
WBOYOriginal
2016-06-13 12:20:301054browse

麻烦大家帮我看下这句代码
$email = isset($fdata['email']) && !empty($fdata['email']) ? htmlspecialchars($fdata['email']) : '';
(htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体。)

?  htmlspecialchars($fdata['email']) : '';这段是什么意思?
------解决思路----------------------
$a=$b?$b:$c;
相当于if($b){$a=$b}else{$a=$c}
------解决思路----------------------
三元运算
结果 = 条件 ? 条件成立时的值 : 条件不成立时的值

等价于
if(条件) {
  结果 = 值
}else {
  结果 = 值
}

在你示例的代码中,这是在做 无效劳动!
因为 Email 中是不会含有 HTML 字符的,否在就是非法的 email
所以有没有 htmlspecialchars 都一样

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