douxiao0400 2012-11-07 14:41
浏览 11
已采纳

比较中的项目顺序[关闭]

I was reading PHP's Array man and I saw this:

<?php
// fill an array with all items from a directory
$handle = opendir('.');
while (false !== ($file = readdir($handle))) {
    $files[] = $file;
}
closedir($handle); 
?>

In the readdir man page, it says "Correctly way of looping".

I'd like to know if there's a difference between X !== false and false !== X. Thanks!

  • 写回答

2条回答 默认 最新

  • dtu36380 2012-11-07 14:42
    关注

    No, there's no difference. The reason you'll sometimes see false == x instead of x == false is that it helps prevent accidentally typing x = false which is permissible in an if or loop structure but is probably not what you want. false = x is nonsensical, and will generate an error instead of silently assigning something.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b