Newbie Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bobthebobert
Forum Commoner
Posts: 25
Joined: Sat Feb 15, 2003 5:56 pm

Newbie Question

Post 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>?
Excess
Forum Newbie
Posts: 3
Joined: Sat Feb 15, 2003 6:50 pm

Newline for each variable.

Post 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.
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post 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)
Post Reply