|
Posted by Robizzle on 10/21/05 02:42
I'm writting a script that produces html source code from form input.
My problem is that I want to format my html source with new lines and
tabs.
So, I have a string that holds all the contents of the source and my
php script displays it by saying
echo '<form><textarea>'.$sourcestring.'</textarea></html>'; All of
that is working currectly except that I don't know how to get the tabs
and new lines in the string.
Here is what I have tried while assinging into the string:
/* This one works but I know there is another way, I hate leaving a php
string open and spanning multiple lines like this */
$sourcestring = '<div class="news" align=left>
<div class="news_titlebar">
<table width=100% border=0>
<tr><td><u>Subject Line</u></td>
<td align="right"><u>Thu, October the 20th 2005 at 7:23pm EST</td>
</tr>
</table>
</div>
<center><hr width=95% /></center>
<div class="news_body">Body of the news post here
<br>
</div>
</div>';
Notice that the '....' remains open for multiple lines of code and that
entire block there is a single assignment expression -- ewww, nasty.
/*This next way is how I tried to fix it, however, it didn't work. The
\t and \n were output to the screen by the echo command. Meaning my
page actually had the backslash and the letters t and n riddled
throughout */
$string = '<div class="news" align=left>\n\t<div
class="news_titlebar">\n\t\t<table width=100%
border=0>\n\t\t\t<tr><td><u>'.'Subject Line'.'</u></td>\n\t\t\t\t<td
align="right"><u>'.'Thu, October the 20th 2005 at 7:23pm
EST'.'</td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>\n\t<center><hr
width=95% /></center>\n\t<div class="news_body">'.'Body of the news
post here'.'\n\t<br>\n\t</div>\n</div>';
I've looked everwhere and all I can figure out is that the escape
characters for strings in php should be \n and \t however these aren't
working for me. Like I said earlier, if I was to say echo '\n\t\n'; I
would literally end up seeing "\n\t\n" printed to the screen instead of
a new line, then a line with only a tab, then a new line.
Navigation:
[Reply to this message]
|