Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post

    Adding space to php echo link

    I am having trouble adding a space between two words in a php link.

    here is my code:
    Code:
                     <?php
      if ( tep_session_is_registered('customer_id') ) {
    echo '<a href="' . tep_href_link(FILENAME_LOGOFF) . '" class="toplinks">'. $customer_first_name  . HEADER_TITLE_LOGOFF. '</a>';
                       }
    else {
     echo '<a href="' . tep_href_link(FILENAME_LOGIN) . '" class="toplinks">' . HEADER_TITLE_LOGIN. '</a>';
             }
    ?>
    So basically if the user with the first name Mike is logged in it displays MikeLogoff

    what the ultimate goal is is to say Welcome Mike (logoff)

  • #2
    Regular Coder funnymoney's Avatar
    Join Date
    Aug 2007
    Posts
    364
    Thanks
    17
    Thanked 24 Times in 24 Posts
    this should do the trick

    instead of your echo try

    PHP Code:
    echo '<a href="' tep_href_link(FILENAME_LOGOFF) . '" class="toplinks">'$customer_first_name  HEADER_TITLE_LOGOFF'</a> '
    it might look the same to you but notice the space after </a>

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Location
    In the wilderness
    Posts
    106
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by funnymoney View Post
    this should do the trick

    instead of your echo try

    PHP Code:
    echo '<a href="' tep_href_link(FILENAME_LOGOFF) . '" class="toplinks">'$customer_first_name  HEADER_TITLE_LOGOFF'</a> '
    it might look the same to you but notice the space after </a>
    Wouldn't that just do the same thing? If your wanting to separate the words you can put another space in between the customers first name and the logoff message like this.

    PHP Code:
    echo '<a href="' tep_href_link(FILENAME_LOGOFF) . '" class="toplinks">'$customer_first_name  ' ' HEADER_TITLE_LOGOFF'</a>'
    "The advantage of computers is that they do exactly what you tell them to do. The disadvantage of computers, on the other hand, is that they do exactly what you tell them to do."

    Excellent resource for learning PHP here

  • #4
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    Thanks karlosio. That worked perfectly. And makes sense.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •