Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP echo add spaces

Tags:

html

php

How do I get some empty spaces after the current logged in user first name is displayed? Just need a few spaces because it's running into something else.

<?php 

if ( is_user_logged_in() ) {
global $current_user;
      get_currentuserinfo();

echo '<span class="white-text">Welcome, &nbsp;' .$current_user->user_firstname     .       "</span>\n";}
?>
like image 949
Patrick Avatar asked Nov 18 '25 10:11

Patrick


2 Answers

A better way would be not to add more spaces, but add a margin:

<span class="white-text" style="margin-right: 5em;">

Change 5em to some other number to change the amount of space.

like image 77
icktoofay Avatar answered Nov 20 '25 00:11

icktoofay


echo '<span class="white-text">Welcome, &nbsp;' .$current_user->user_firstname . "  &nbsp; &nbsp;&nbsp;&nbsp; </span>\n";

each &nbsp; is a "non-breaking space"

like image 27
Scott Yang Avatar answered Nov 19 '25 23:11

Scott Yang