PHP7.1数据类型转换持续记录
1. 数值型与字符串运算
a. var_dump('one' + 5) # int(5), Warning: A non-numeric value encountered in...
b. var_dump(5 / 'one') # float(INF),Warning: A non-numeric value encountered in... , Warning: Division by zero in...
c. var_dump(6 / '2one') # int(3),Notice: A non-numeric value encountered in...
d. var_dump(5 / '2one') # float(2.5), Notice: A non-numeric value encountered in...
e. var_dump('5' % 2) # int(1)
f. var_dump('5.4' % 6) # int(5)
g. var_dump('5.4one' % 6) # int(5), Notice: A non-numeric value encountered in...
h. var_dump(5 / '3.3') # float(1.5151515151515)
i. var_dump(5 % '3.3') # int(2)
2. 数值型与字符串比较
a. var_dump(5 == '5') # bool(true)
b. var_dump(5 === '5') # bool(false)
c. var_dump(5 < '5.4') # bool(true)
上一篇: 详解 Python3 正则表达式(三)
下一篇: Go 处理yaml类型的配置文件