| | |
View HTML source in php page?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hey, I created a little form for my sister to use to create her eBay pages on the fly. Basically she inputs the background colors, text colors, description, pictures, all that jazz, and the form generates the html with the information she provided.
I want to make it easy for her to get the source code of the page, exactly as it's output, and I don't want her to have to rely on the "View Source" in IE.
So how can get all the html I've generated in my php script, and put it like in a little textarea box where she can highlight it all and copy it to her clipboard?
I want to make it easy for her to get the source code of the page, exactly as it's output, and I don't want her to have to rely on the "View Source" in IE.
So how can get all the html I've generated in my php script, and put it like in a little textarea box where she can highlight it all and copy it to her clipboard?
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
Assuming the generated page is stored in a variable $page:
php Syntax (Toggle Plain Text)
echo '<textarea name="source">'.htmlspecialchars($page).'</textarea>';
Last edited by php_daemon; Jan 23rd, 2007 at 6:17 pm.
•
•
•
•
Assuming the generated page is stored in a variable $page:
php Syntax (Toggle Plain Text)
echo '<textarea name="source">'.htmlspecialchars($page).'</textarea>';
[PHP]$page = "<html><body>content...";[/PHP]
But that didn't seem to work. But maybe it's because I wasn't using that htmlspecialchars thing?
But I'll try that with what you gave me and see if it works.
Thanks.
•
•
Join Date: Aug 2006
Posts: 138
Reputation:
Solved Threads: 2
Ah, I see. You could use output buffering to make it nicer:
php Syntax (Toggle Plain Text)
ob_start(); //page creation goes here //... $page=ob_get_contents(); //get the page echo '<textarea name="source">'.htmlspecialchars($page).'</textarea>'; ob_end_flush(); //output to browser
Last edited by php_daemon; Jan 24th, 2007 at 12:25 pm.
![]() |
Similar Threads
- updating 2 HTML tables on one PHP page (PHP)
- Connot see HTML source on IE6 (Web Browsers)
Other Threads in the PHP Forum
- Previous Thread: URL parsing to get variables name
- Next Thread: Warning: mysql_fetch_array():
Views: 4940 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl customizableitems database date development directory display download dynamic echo email error file files folder form forms forum function functions google headmethod href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail malfunctioning menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube





