小编tag*_*tag的帖子

如何将布尔值转换为字符串

我有一个布尔变量,我想将其转换为字符串

$res = true;
Run Code Online (Sandbox Code Playgroud)

我需要它转换值也处于格式"true" "false""0" "1"

$converted_res = "true";
$converted_res = "false";
Run Code Online (Sandbox Code Playgroud)

我试过了:

$converted_res = string($res);
$converted_res = String($res);
Run Code Online (Sandbox Code Playgroud)

但它告诉我string并且String不是公认的功能.如何在php中将此布尔值转换为格式为"true"或"false"的字符串?

php string

210
推荐指数
6
解决办法
18万
查看次数

标签 统计

php ×1

string ×1