ProAnswers.org

How do I convert the value of a PHP variable to string?

I was looking for something better than concatenating with an empty string:

$myText = $myVar . ‘’;

like the ToString() method in Java or .NET.

You can use the [casting operators](http://us3.php.net/manual/en/language.types.type-juggling.php):

$myText = (string)$myVar;

There are more details for string casting and conversion in the [Strings section](http://us3.php.net/manual/en/language.types.string.php#language.types.string.casting) of the PHP manual, including special handling for booleans and nulls.