php 中怎样将字符串转换成数值类型

2025-04-25 18:04:44
推荐回答(1个)
回答1:

php一般进行自动转换。当然也可以强制转换。
$str="123abc";
echo (int)$str;
函数intval()也能转换,不过不改变原字符串。(int)可以改变原字符串。