Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add space in PHP between two outputs

Tags:

html

php

spacing

I am new to php and trying to do this:

<html>
<body>
<?php
echo 'Welcome'.$_GET['name'];
?>
</body>
</html>

This is my php code which displays my name entered by using a html form. When submit button is pressed I get this output :- WelcomeNick Watterson

But I am trying to add space between Welcome and Nick. How can I do this in this code?

like image 491
user2439492 Avatar asked Oct 28 '25 23:10

user2439492


1 Answers

use the below code

<?php
echo 'Welcome&nbsp;'.$_GET['name'];
?>

  is the html entity code for creating an single space character.

You can also use the below code:

<?php
    echo 'Welcome '.$_GET['name'];
 ?>

Will also work because one empty space is interpreted by the browsers directly.

like image 74
Sourabh Kumar Sharma Avatar answered Oct 31 '25 13:10

Sourabh Kumar Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!