Jump to content

opposite of \n ?


sniffledog

Recommended Posts

 

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.

 

Link to comment
https://forums.phpfreaks.com/topic/77380-opposite-of-n/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/77380-opposite-of-n/#findComment-391736
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/77380-opposite-of-n/#findComment-391778
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.