简体   繁体   中英

PHP runtime type checking

I am trying to figure out the order in which PHP check types/object during runtime. So I can become a better coder. Thanks

Which type do php check first. Does it validate if a object is Boolean first? null? array?

which faster:

if (ID != null)

if (ID !== false)

if (ID == 0)

These are micro-optimizations. Your time would be spent better optimizing something else.

I'm not sure if there are any comparisons on this, but check out http://www.phpbench.com .

Also, you may take a look at http://php.net/manual/en/types.comparisons.php and http://php.net/manual/en/language.operators.precedence.php , although they do not give you benchmarks.

Again, your time would likely be spent better focusing on optimizing something else.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM