sniffledog Posted November 14, 2007 Share Posted November 14, 2007 this is probably not the toughest question but i can't find the answer so hopefully one of you freaks knows the answer. when you echo text in php you use a \n to create a new line or paragraph break or what ever it's supposed to be called. the issue i'm having is when you echo a variable like: <? $var = "text"; echo "Variable = [ $var ]" ?> the output displays a line break after the variable so it looks like: Variable = [ text ] does anyone know how to make php not display a line break after variables? is there an opposite of \n or something? either way any help is appreciated. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted November 14, 2007 Share Posted November 14, 2007 I just tested your code and I did not get a line break. see what happens when you do this: <?php $var = "text"; echo "Variable = ["; echo "$var"; echo "]"; ?> also \n does not create physical line break in your html code; it only creates a line break in your source code, but < br> does create a physical line break in your html code. Quote Link to comment Share on other sites More sharing options...
effigy Posted November 14, 2007 Share Posted November 14, 2007 HTML has NOBR. Quote Link to comment Share on other sites More sharing options...
sniffledog Posted November 14, 2007 Author Share Posted November 14, 2007 thank you both for your replies, the code provided by the phpQuestioner helped me figure out what was causing the line break in the output. the variable i was using was actually a command enclosed with back ticks like: $var = `w | head -1 | cut -d" " -f13 | cut -d"," -f1`; i changed that to: $var = exec('w | head -1 | cut -d" " -f13 | cut -d"," -f1'); and the line break in the output went away. and again i thank you all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.