Page 1 of 1

PHP Linebreaks, NOT <br />

Posted: Mon Jun 21, 2004 5:02 pm
by randomblink

Code: Select all

<?php
$html .= "<tr class="msgTitle_" . $messageType . "Message">";
$html .= "<td class="msgImageHolder" rowspan="2" onclick="flick( $jsScript );return false;">";
$html .= $imgHandler . $this->_msgReadYet( $message['read_yet'] ) . $this->_msgFromIcon( $message['alliance'] ) . "</td>";
$html .= "<td colspan="2">" . $message['title'] . " - [" . $message['date'] . "::" . $message['time'] . "]</td>";
?>
Ok...
This is sample code.
Return $html; gives me jumbled together HTML.
I am TRYING to create clean code for the output.
I want each HTML Tag to be on a newline in the resultant PHP->Output.
In other words, when I run the script... And I get an HTML page, I want to view source and SEE a clean HTML Code.

Can anyone help me out here?
I have tried nl2br, but this puts <br /> EVERYWHERE! No good... I just need each HTML Tag to be on a new line... HELP!

Posted: Mon Jun 21, 2004 5:06 pm
by feyd
\n

Posted: Mon Jun 21, 2004 6:20 pm
by PrObLeM
feyd wrote:\n
oh how short and simple ...bravo feyd bravo!

Posted: Mon Jun 21, 2004 6:52 pm
by WaldoMonster
This is also a possibility:

Code: Select all

<?php
$html = '<table cellspacing="2" cellpadding="2" border="1">
<tr align="center">
    <td>This is</td>
    <td>also</td>
</tr>
<tr align="center">
    <td>a</td>
    <td>possibility</td>
</tr>
</table>
';

echo $html;
?>

Posted: Mon Jun 21, 2004 9:40 pm
by John Cartwright
WaldoMonster wrote:This is also a possibility:

Code: Select all

<?php
$html = '<table cellspacing="2" cellpadding="2" border="1">
<tr align="center">
    <td>This is</td>
    <td>also</td>
</tr>
<tr align="center">
    <td>a</td>
    <td>possibility</td>
</tr>
</table>
';

echo $html;
?>
make sure you escape the single quotes when parsing variables..

for example

Code: Select all

<?php

html = 'this is escaping '. $foobar .' so the variable will get parsed';
?>

Posted: Tue Jun 22, 2004 12:03 am
by Illusionist
Phenom wrote:
WaldoMonster wrote:This is also a possibility:

Code: Select all

<?php
$html = '<table cellspacing="2" cellpadding="2" border="1">
<tr align="center">
    <td>This is</td>
    <td>also</td>
</tr>
<tr align="center">
    <td>a</td>
    <td>possibility</td>
</tr>
</table>
';

echo $html;
?>
make sure you escape the single quotes when parsing variables..

for example

Code: Select all

<?php

html = 'this is escaping '. $foobar .' so the variable will get parsed';
?>
uhm... I dont see any reason there that he would need to escape anything for any variable. Where did that comment come from?

Posted: Tue Jun 22, 2004 12:10 am
by kettle_drum
Its as the example used single quotes - which would just show $blah instead of what was held in the var. At least thats what i understand from it.

Posted: Tue Jun 22, 2004 12:12 am
by Illusionist
Yes thats true, but i was just asking why he posted that when he wasn't trying to pass a variable through or anything....

Posted: Tue Jun 22, 2004 12:12 am
by kettle_drum
Yeah true :P

(Just trying to get to 400 posts before i go to bed.)

Posted: Tue Jun 22, 2004 12:16 am
by Illusionist
:-D hehe