如题所述
第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 是字符串类型