WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES

How to Convert an Integer to a String in PHP

Topic: PHP / MySQLPrev|Next

Answer: Use the strval() Function

You can simply use type casting or the strval() function to convert an integer to a string in PHP.

Let's take a look at an example to understand how it basically works:

<?php
// Sample integer
$int = 10; 

// Casting integer to string
$var1 = (string) $int;  // $var1 is a string
var_dump($var1);

// Getting string value of a variable
$var2 = strval($int);  // $var2 is a string
var_dump($var2);
?>

Related FAQ

Here are some more FAQ related to this topic:

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties