3

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";}
?>
0

6 Answers 6

2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

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

1 Comment

it's a Non-breaking space not a non-blank space
1

Your code isn't working because the extra spaces are ignored, this is normal. Only the first space character will be outputted, if you want more, use &nbsp; (non-breaking space).

You can also put a margin on the text with CSS:

span.white-text {
    margin: 5px;
}

Comments

1

I've been faced with a similar problem and after much trial and error found that this works for my code line, inserting a space between First Name and Surname - so something similar may well work for yours...

<option value=<?php echo $row ["First_Name"], "&nbsp;", $row["Surname"] ; ?>>

Comments

0

try this

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

1 Comment

remove &nbsp; just use " "
0
echo "<td>" . $info['id'] . "</td>";
echo "<td></td>";
echo "<td></td>";
echo "<td>" . $info['refid'] . "</td>";
echo "<td></td>";
echo "<td></td>";
echo "<td>" . $info['username'] . "</td>";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.