How to Convert Boolean to String

后端 未结 15 810
死守一世寂寞
死守一世寂寞 2020-11-28 02:43

I have a Boolean variable which I want to convert to a string:

$res = true;

I need the converted value to be of the format: \"true\"

15条回答
  •  情书的邮戳
    2020-11-28 03:08

    Another way to do : json_encode( booleanValue )

    echo json_encode(true);  // string "true"
    
    echo json_encode(false); // string "false"
    
    // null !== false
    echo json_encode(null);  // string "null"
    

提交回复
热议问题