How to Convert Boolean to String

后端 未结 15 749
死守一世寂寞
死守一世寂寞 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:28

    The function var_export returns a string representation of a variable, so you could do this:

    var_export($res, true);
    

    The second argument tells the function to return the string instead of echoing it.

提交回复
热议问题