Page 1 of 1
The Naked Truth
Posted: Thu Jun 23, 2005 9:44 pm
by harrison
Hi, I am debugging my application and i want to display my HTML str in raw after I displayed it right.
What I mean is:
1. Display the HTML str I get from some class method, DisplayPage()
2. Debug the page by displaying the raw HTML.
Any idea?
Posted: Thu Jun 23, 2005 9:51 pm
by neophyte
I'm not entirely sure what your after. Here's a guess.
<pre></pre>
Posted: Thu Jun 23, 2005 9:54 pm
by harrison
No, <pre> is for formatting text. I want to display the string together with HTML tags in it.
Sorry if i made you confused.
Posted: Thu Jun 23, 2005 9:59 pm
by dethron
by replacing
<
>
&
"
with
<
>
&
"
(hope it helps)
Posted: Thu Jun 23, 2005 9:59 pm
by John Cartwright
depending how your script is setup, if you compile all your output into a string and apply the proper formatting -- much like a templating engine you could simply run your final output through
htmlentities().
Now if you have been echo'ing out your output through the processing of your script, you could create a function that uses
ob_get_contents() and grab any output sent to the browser, apply htmlentities and output the newly formatted html.
Posted: Thu Jun 23, 2005 10:01 pm
by harrison
Wow, dethron. I never think about that before.

I was expecting for a function but you got it right. Thanks.
Edited: I will try what jcart said.
Posted: Thu Jun 23, 2005 10:03 pm
by dethron
your welcome, and now i am checking htmlentities() as Jcart pointed out.
Code: Select all
<?php
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
?>
Posted: Thu Jun 23, 2005 10:08 pm
by harrison
htmlentities() is perfect! I just need to use it with <PRE> because it loses its fomatting.
Code: Select all
function RawHTML($str){
return '<br><b>Raw HTML</b><hr><pre>'.htmlentities($str).'</pre>';
}
Thank you all.
Posted: Mon Jun 27, 2005 9:54 am
by djot
-
Why not using something like codebeautifier?
Or just put the plain html into a textarea-tag
djot
-
Posted: Mon Jun 27, 2005 8:14 pm
by harrisonad
Sounds like a good ideo but i only need it for HTML debugging purpose.
Thank you all.