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

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

WBOY
Release: 2016-06-13 12:20:30
Original
1093 people have browsed it

麻烦大家帮我看下这句代码
$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 都一样

Related labels:
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