Underlying philosophy behind php type comparisons

前端 未结 7 1827
不思量自难忘°
不思量自难忘° 2021-02-10 00:38

So there\'s this page on the php site which shows the result of comparing different values:

http://php.net/manual/en/types.comparisons.php

This is a helpful refe

7条回答
  •  南笙
    南笙 (楼主)
    2021-02-10 01:10

    If the value contains something then it can be said to be true. For example, 1, 1.123, array("value"), etc. are all treated as true.

    If the value can be said to be empty or void (i.e. lacking something) then it is seen as false. For example, 0, 0.0, array(), and so on.

    This way of thinking about variables is not special to PHP. Many other languages do it in the same or similar way. E.g. Perl, C and Javascript, just to name a few.

提交回复
热议问题