The Naked Truth
Moderator: General Moderators
The Naked Truth
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?
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?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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.
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.
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);
?>htmlentities() is perfect! I just need to use it with <PRE> because it loses its fomatting.
Thank you all.
Code: Select all
function RawHTML($str){
return '<br><b>Raw HTML</b><hr><pre>'.htmlentities($str).'</pre>';
}- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact: