This topic created in 4943 days ago, the information mentioned may be changed or developed.
如果字段是空值这样返回的 0 的类型是 string,除了在 PHP 端遍历结果集去写 (int) 以外,有没有什么更好的办法让返回值的类型是 int
4 replies • 1970-01-01 08:00:00 +08:00
 |
|
PHP 的变量是没有类型的,如果比较 ‘0’ == 0 就是相等,不需要强制转换。
|
 |
|
@ soonlai 但是用作 API 返回值 json_encode 后 其他语言是有类型检查的
|
 |
|
javascript 比较 '0' == 0 也是相等的,是不是你是在 decode 的时候异常了,这就需要转换了。
|
 |
|
@ soonlai 不是,有些插件比如 highchart 如果数据类型不是 int 就不会正常的显示结果
|