“php”字符串如何转换成数字?

如题所述

第1个回答  2022-11-16
1.强制类型转换方式 \x0d\x0a$foo = "1"; // $foo 是字符串类型 \x0d\x0a$bar = (int)$foo; // $bar 是整型 \x0d\x0a\x0d\x0a2.内置函数方式 \x0d\x0a$foo = "1"; // $foo 是字符串类型 \x0d\x0a$bar = intval($foo); // $bar 是整型 \x0d\x0a\x0d\x0a3.格式化字符串方式 \x0d\x0a$foo = "1"; // $foo 是字符串类型 \x0d\x0a$bar = sprintf("%d", $foo); // $bar 是字符串类型

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网