PHP casting operators

$myText = (string)$myVar;

There are more details for string casting and conversion in the Strings section of the PHP manual, including special handling for booleans and nulls.

The casts allowed are:

  • (int), (integer) – cast to integer
  • (bool), (boolean) – cast to boolean
  • (float), (double), (real) – cast to float
  • (string) – cast to string
  • (array) – cast to array
  • (object) – cast to object
  • (unset) – cast to NULL (PHP 5)

 

Source

http://us3.php.net/manual/en/language.types.type-juggling.php

Leave a comment