Page 1 of 1

Newbie Question

Posted: Sat Feb 15, 2003 5:56 pm
by bobthebobert
Take this code:

Code: Select all

<?php
echo $a;
echo $b;
echo $c; 
echo $d;
echo $e;
echo $f;
echo $g;
echo $h;
?>
How would you go about making them not print out on the same line, but on different lines? Would it require you to get out of php everytime and <br>?

Newline for each variable.

Posted: Sat Feb 15, 2003 6:50 pm
by Excess
Try this.

Code: Select all

<?php 
echo "$a <br>"; 
echo "$b <br>"; 
echo "$c <br>"; 
echo "$d <br>"; 
echo "$e <br>"; 
echo "$f <br>"; 
echo "$g <br>"; 
echo "$h <br>"; 
?>
You are sending output to the browser. Just enclose it all in double quotes with a br tag and the browser will interpret this as it reads it.
ie: value of $a, break, value of $b, break, etc.

Posted: Sat Feb 15, 2003 7:16 pm
by lazy_yogi
I prefer this .. but it's just anther choice of coding style

Code: Select all

echo $a."<br>"; 
echo $b."<br>"; 
echo $c."<br>"; 
echo $d."<br>"; 
echo $e."<br>"; 
echo $f."<br>"; 
echo $g."<br>"; 
echo $h."<br>";

(off topic : interesting signature Excess)