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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England
    Posts
    172
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to stop a space showing up after an echo?

    PHP Code:
    <? $test "Hello"?>

    Richard says <? echo $test?>.
    This is just an example of a larger script, but when executed in the browser, the end result is this:

    Richard says Hello .

    Why is there always a space between the script and whatever follows it, even though there's no space between the closing bracket and period in the script itself? How do you stop it doing that?
    \o/

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Ok, well I'm not sure about you, but there is no problem with that script, I ran it and it came out "Richard says Hello." no space after the echo, have you actually checked if the variable set on the larger script has a space after it? And I would suggest that you change the <? to <?php but other than that, no problem..

  • #3
    Regular Coder Masterslave's Avatar
    Join Date
    Dec 2005
    Posts
    287
    Thanks
    2
    Thanked 0 Times in 0 Posts
    If you use this:
    PHP Code:
    Richard says <? echo trim$test ); ?>.
    Does the space still exists?


  •  

    Posting Permissions

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