PHP echo space between variables
In this article, we will see PHP echo space between variables and multiple white spaces.
Multiple White Space
If there is more than one white space in a string; then the browser collapses all those white spaces into a single white space. Hence to add more than one white space in between words or characters we can use an HTML entity
- – indicates nonbreakable whitespace, which adds a single space.
we can use any number of times to add more white spaces.
Example
<?php
echo "Hello World!";
?>
/*Output:
Hello World!
*/
-
- In the above code, we printed “hello world”. I want to add five spaces between the variable.
- If you write the code below to insert five spaces:
<?php echo "Hello World!"; ?>
You will get only one space output like this:
Output: Hello World!
- So, we use the “ ” statement to add multiple white space in PHP.