•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,809 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,524 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1918 | Replies: 4
![]() |
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:
Rep Power: 3
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 5:17 pm.
•
•
•
•
Assuming the generated page is stored in a variable $page:
php Syntax (Toggle Plain Text)
echo '<textarea name="source">'.htmlspecialchars($page).'</textarea>';
Well, that's the problem, I don't really know how to store the generated page in a variable, because on the php page, it has a bunch of variables and stuff, and I don't know how to get it all stored into a variable. I tried simply doing like:
[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:
Rep Power: 3
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 11:25 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
blog code competition computer css daniweb dell development div dreamweaver drivers firefox games gpl graphics html intel internet java linux microsoft microsystems mozilla news open open source open-source openbsd opengl operating php red hat security software source sun super symantec system tables ubuntu vista w3c web wesnoth windows wysiwyg xml xp
- 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():


Linear Mode