有没有更好的选择? [英] What's better, isset or not?

查看:62
本文介绍了有没有更好的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两者之间是否有速度差异

Is there any speed difference between

if (isset($_POST['var']))

if ($_POST['var'])

哪个更好还是相同?

推荐答案

出于以下原因,使用isset是一个好习惯:

It is a good practice to use isset for the following reasons:

  • 如果$_POST['var']是空字符串或"0",则isset仍会检测到该变量存在.
  • 不使用isset会生成通知.
  • If $_POST['var'] is an empty string or "0", isset will still detect that the variable exists.
  • Not using isset will generate a notice.

这篇关于有没有更好的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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