Site Admin
Site Admin Founder of MeaningArticles

PHP Convert Integer to a string Example

Hello Dev.

Converting Integer to a string in php is not that difficult, we can use PHP’s built-in strval() function. This function is fully capable of converting string, Integer and double to a string. The important thing is to remember about this function is it shouldn’t be used with objects and arrays; if used, then this will return the type name.

So let's start the lesson...


The Strval Function Syntax

strval( $var )

This function takes one parameter, and that is the numerical value which needs to be converted to string. This function returns the string value as you can see in the below example.

    $var = 124.061; 
    echo strval($var); 

// Result: 124.061

I hope it assists you, thanks for visiting my article if you like my article then share it with your friends on the social media platform.

Happy Coding.....