Convert an Integer Into a String in PHP code example

Example 1: Convert an Integer Into a String in PHP

phpCopy<?php  
$variable = 10;
$string1 = (string)$variable;
echo "The variable is converted to a string and its value is $string1.";  
?>

Example 2: Convert an Integer Into a String in PHP

phpCopy<?php  
$variable = 10;
$string1 = strval($variable);
echo "The variable is converted to a string and its value is $string1.";  
?>

Example 3: Convert an Integer Into a String in PHP

phpCopystrval($variableName);

Example 4: Convert an Integer Into a String in PHP

phpCopy$string = (string)$intVariable

Example 5: Convert an Integer Into a String in PHP

phpCopy<?php  
$variable = 10;
echo "The variable is converted to a string and its value is $variable.";  
?>

Example 6: Convert an Integer Into a String in PHP

phpCopy$integer = 5;
echo "The string is $integer";

Example 7: Convert an Integer Into a String in PHP

phpCopy<?php  
$variable = 10;
$string1 = "".$variable;
echo "$string1";  

$string1 = $variable."";
echo "$string1";  

?>

Example 8: Convert an Integer Into a String in PHP

phpCopy<?php  
$variable = 10;
$string1 = "The variable is converted to a string and its value is ".$variable.".";
echo "$string1";  
?>

Example 9: Convert an Integer Into a String in PHP

phpCopy"First string".$variablename."Second string"

Tags:

Php Example