Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
数据类型 | 标量类型 | 复合类型 | 特殊类型 |
---|---|---|---|
1 | bool 布尔型 | array 数组 | null |
2 | int 整形 | object 对象 | resource 资源类型 |
3 | string 字符串 | ||
4 | float 浮点型 |
$uid = 1;
(bool)$uid => bool(true) => boolean
(int)$uid => int(1) => integer
(string)$uid => string(1) => string
(float)$uid => float(1) => double
(array)$uid => array(1) { [0]=> int(1) } => array
(object)$uid => object(stdClass)#1 (1) { ["scalar"]=> int(1) } => object
$uid = '1'; => string(1) "1"
$uid += 5.5; => float(6.5)
$uid += 1; => int(2)
$uid = null; => null
$uid += 1; => int(1)
$uid += '1'; => int(1)
$username = null;
(bool)$username) => bool(false)
// null 在布尔类型中被转换成false
$uid = '1'; => string
settype($uid, 'int'); =>integer/int
settype($uid, 'float'); =>double/float
$a = 10;
$b = $a;
printf('$a的值%d, $b的值%d', $a,$b);
=> $a的值10, $b的值10
$a = 100;
printf('$a的值%d, $b的值%d', $a,$b);
=> $a的值100, $b的值10
$a = 10;
$b = &$a; //$b直接引用$a的值
printf('$a的值%d, $b的值%d', $a,$b);
=> $a的值10, $b的值10
$a = 100;
printf('$a的值%d, $b的值%d', $a,$b);
=> $a的值100, $b的值100