Uppercase Booleans vs. Lowercase in PHP

后端 未结 11 2101
无人共我
无人共我 2020-12-23 02:33

When I was learning PHP, I read somewhere that you should always use the upper case versions of booleans, TRUE and FALSE, because the \"normal\" lo

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-23 03:26

    I've written simple code to check the differences between false and FALSE: Each iteration was doing something that:

        for ($i = 0; $i < self::ITERATIONS; ++$i) {
           (0 == FALSE) ;
        }
    

    Here are the results:

    Iterations: 100000000
    using 'FALSE': 25.427761077881 sec
    using 'false': 25.01614689827 sec
    

    So we can see that performance is very slightly touched by the booleans case - lowercase is faster. But certainly you won't see.

提交回复
热议问题