Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    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)

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    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)

  • #4
    me'
    me' is offline
    Senior Coder
    Join Date
    Nov 2002
    Location
    Warwickshire, England
    Posts
    1,229
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Last edited by ReadMe.txt; 12-22-2003 at 06:54 PM.
    "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)

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    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)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •