How to use Inline variable parsing. In PHP
Note: When you use Integer inside a string, then the Integer is first converted into a string and then prints as a string.
Syntax:
$integer = 2;
echo "$integer";
Example:
<?php
$var_name = 2;
// prints the value of above variable
// as a string
echo "Welcome $var_name w3wiki";
?>
Output
Welcome 2 w3wiki
How to convert an Integer Into a String in PHP ?
The PHP strval() function is used to convert an Integer Into a String in PHP. There are many other methods to convert an integer into a string.
In this article, we will learn many methods.
Methods:
Table of Content
- Using strval() function.
- Using Inline variable parsing.
- Using Explicit Casting.
- Using sprintf() Function
- Using concatenation with an Empty String
Contact Us