Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-21-2003, 02:18 AM   PM User | #1
zapa
New to the CF scene

 
Join Date: Dec 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
zapa is an unknown quantity at this point
display html source in textarea

I would like to display a html file after it has been rendered with php in Text area so user can copy or edit souce code.

I was able to open html file and print it fine. but it shows the PHP code and its not wha the final html output source looks like.

So can someone help me by showing me how i can do something like this.

thanks in advance,
zap
zapa is offline   Reply With Quote
Old 12-21-2003, 09:22 AM   PM User | #2
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
Absolute url ...

PHP Code:
<textarea name="whatever">
<?include 'http://domain.com/your/file.php';?>
</textarea>
would show the HTML output of file.php , wheras

include '/home/user/www/your/file.php';

would show the PHP code.
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 12-22-2003, 04:02 PM   PM User | #3
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
DOH

Stuntboy just pointed out that the code I posted above would lead to an infinate loop and possible server death if you are trying to show HTML output of the current file !

that's not how I originally read your question but that appears to be what you actually meant ?

I am definately going to have to put a disclaimer in my sig somewhere

So working on an answer now if Stunt does not beat me to it
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Old 12-22-2003, 04:10 PM   PM User | #4
me'
Senior Coder

 
Join Date: Nov 2002
Location: Warwickshire, England
Posts: 1,229
Thanks: 0
Thanked 0 Times in 0 Posts
me' is an unknown quantity at this point
Here's how it's done client side, anway: (pulled from a favelet so the code might not be completely relevant)
Code:
function(){
  %20function%20htmlEscape(s){
   s=s.replace(/&/g,'&');
    s=s.replace(/>/g,'&gt;');
    s=s.replace(/</g,'&lt;');
    return%20s;
  }
%20x=window.open();
%20x.document.write(
  '<pre>'%20
  +%20htmlEscape('<html>\n'%20
    +%20document.documentElement.innerHTML%20
    +%20'\n</html>'));
%20x.document.close();%20})();
__________________
David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!
me' is offline   Reply With Quote
Old 12-22-2003, 04:30 PM   PM User | #5
ReadMe.txt
Regular Coder

 
Join Date: Jun 2002
Location: Sheffield, UK
Posts: 552
Thanks: 0
Thanked 0 Times in 0 Posts
ReadMe.txt is an unknown quantity at this point
how about

PHP Code:
<?
if(!isset($_GET['sourced'])) {
echo 
'<textarea>';
include(
'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?sourced=yes');
echo 
'</textarea>';
}
?>
not sure about the ligitmacy of using querystrings from within an include call however.

EDIT: no more typo
__________________
"To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

(Me Me Me Me Me Me Me Me Me)

Last edited by ReadMe.txt; 12-22-2003 at 05:54 PM..
ReadMe.txt is offline   Reply With Quote
Old 12-22-2003, 05:06 PM   PM User | #6
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,904
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
that works a treat , just a typo here

if(!isset($_GET['sourced']))

but better a typo than infinate recursion
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:44 PM.


Advertisement
Log in to turn off these ads.