PHP知识收藏

记录一些 php 基础知识点

语法

判断是否为空

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+--------------+-----------+---------+-----------+---------+--------+
| 真值表 | gettype() | empty() | is_null() | isset() | (bool) |
+--------------+-----------+---------+-----------+---------+--------+
| $x = "" | string | true | false | true | false |
| $x=null | NULL | true | true | false | false |
| var $x | NULL | true | true | false | false |
| $x = array() | array | true | false | true | false |
| $x = false | boolean | true | false | true | false |
| $x = 15 | integer | false | false | true | true |
| $x = 1 | integer | false | false | true | true |
| $x = 0 | integer | true | false | true | false |
| $x = -1 | integer | false | false | true | true |
| $x = '15' | string | false | false | true | true |
| $x = '1' | string | false | false | true | true |
| $x = '0' | string | true | false | true | false |
| $x = '-1' | string | false | false | true | true |
| $x = 'foo' | string | false | false | true | true |
| $x = 'true' | string | false | false | true | true |
| $x = 'false' | string | false | false | true | true |
+--------------+-----------+---------+-----------+---------+--------+
Author: rexmolo
Link: http://rexmolo.github.io/2019/04/11/php-knowledge-collection/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.