loadHTMLFile->(current file that has been output by php)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ManWithNoName
    New Member
    • Aug 2007
    • 88

    loadHTMLFile->(current file that has been output by php)

    Hello, this is my third post (i.e. starting a thread), please be gentle.

    I have a PHP file that outputs a html file (the usual PHP echo stuff, no funny business... Well PHP outputs it from a XML file... ).

    Now, I want to load that file (the HTML file that is). But that file is a temp file created by PHP.

    My question is thus: how, if possible, do I do that?
    Last edited by ManWithNoName; Sep 2 '07, 01:23 PM. Reason: My parents divorced, and it was all my fault.
  • etiainen
    New Member
    • Aug 2007
    • 40

    #2
    You could fprintf() it somewhere instead of echoing...
    @see: http://www.php.net/manual/en/function.fprint f.php

    Comment

    • ManWithNoName
      New Member
      • Aug 2007
      • 88

      #3
      Originally posted by etiainen
      You could fprintf() it somewhere instead of echoing...
      @see: http://www.php.net/manual/en/function.fprintf.php
      Thanks for your reply, but I'm not sure if I'm following you. I took a look at the fprintf function, but I can not see how it would help me, because I do not know the file that is going to be handled (fprintf(par1)) .
      Last edited by ManWithNoName; Sep 2 '07, 01:53 PM. Reason: The forcast for today was somewhat cloudy

      Comment

      • ManWithNoName
        New Member
        • Aug 2007
        • 88

        #4
        ... I think that I'm looking for the PHP output buffer file, is this correct?

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, ManWithNoName.

          Are you trying to capture output that is being echoed? Or are you trying to locate a temporary file whose name is unknown?

          Comment

          • ManWithNoName
            New Member
            • Aug 2007
            • 88

            #6
            Originally posted by pbmods
            Heya, ManWithNoName.

            Are you trying to capture output that is being echoed? Or are you trying to locate a temporary file whose name is unknown?
            Thanks for your reply.

            Well... Yes... I thought I was doing both...? Gee, now I'm confused...

            I have a output (echoed from PHP) as html and I want to do stuff with it (DOM stuff). So I guess I want top capture the output, but after the file has been rendered. So... I do not want to capture the output?

            I have to find the temporary file that is unknown?

            I have currently solved the problem by making PHP output my XML file as a HTML file in the current directory and then I load that HTML file (instead of outputting ("echo") the XML file directly to the browser.

            Does this make any sense? I feel so funny in the head right now...

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Heya, ManWithNoName.

              You may find output buffering to be useful.

              Simply call ob_start() before your script outputs anything.

              Once you're ready to process your HTML, call ob_get_contents () to save everything to a variable.

              Then call ob_end_clean() to clear the buffer and turn off output buffering, or you can use ob_end_flush() to send the *buffered* output to the browser.

              Here's an example:
              [code=php]
              <?php
              /***************
              *
              * Start output buffering.
              */
              ob_start();

              /***************
              *
              * This won't get output.
              */
              echo 'Hello, World!';

              /***************
              *
              * Capture buffered output.
              */
              $str = ob_get_contents ();

              /***************
              *
              * Clear the buffer. This also turns off output buffering.
              */
              ob_end_clean();

              /***************
              *
              * Outputs:
              * Hello, ManWithNoName!
              */
              echo str_replace('Wo rld', 'ManWithNoName' , $str);
              ?>
              [/code]

              Comment

              • ManWithNoName
                New Member
                • Aug 2007
                • 88

                #8
                Originally posted by pbmods
                Heya, ManWithNoName.

                You may find output buffering to be useful...

                [/code]
                Hehe, cute example, thanks!

                However, I found some tutorial about the "ob-gang" . And that was not quite what I was looking for.

                My problem was that I was trying to output Hello World (i.e. not stop it), and after that remove it... Using PHP and XhttpReq... Yeah, I know...

                After a dozen futile attempts, I have given up.

                My last attempt to control 'what I am trying to control' is with htacces, let's see if it will go any better... Somehow I doubt it. I doubt it very much.

                Anyway, thanks for trying to help me with this problem!

                Comment

                • ocpaul20
                  New Member
                  • Jul 2007
                  • 7

                  #9
                  I could be being completely stupid here, but it sounds like you want to use PHP to create an HTML file in your current directory(or wherever). Then read it in, change bits of it, and then send it to the browser.

                  The php echo command usually sends it straight to the browser, so if you want to change it after being output from PHP and before it gets to the browser, perhaps you need to output the HTML to a file first, process that file, then send it to the browser.

                  Comment

                  • ManWithNoName
                    New Member
                    • Aug 2007
                    • 88

                    #10
                    Originally posted by ocpaul20
                    I could be being completely stupid here, but it sounds like you want to use PHP to create an HTML file in your current directory(or wherever). Then read it in, change bits of it, and then send it to the browser.

                    The php echo command usually sends it straight to the browser, so if you want to change it after being output from PHP and before it gets to the browser, perhaps you need to output the HTML to a file first, process that file, then send it to the browser.
                    Yes, you're completely right, and that is why...

                    I have currently solved the problem by making PHP output my XML file as a HTML file in the current directory and then I load that HTML file (instead of outputting ("echo") the XML file directly to the browser.
                    The problem was, as stated above, that I wanted to:
                    1. Create the html (or locate the temp file).
                    2. Show it to the user.
                    3. And thereafter change it (using "AJAX"/PHP).

                    While this isn't impossible the reason I wanted to do it was; it was polluted with perverted logic; I would blame it on poor sleep and a working with the project for a very long time.


                    Anyway, thanks for your input!

                    Comment

                    • pbmods
                      Recognized Expert Expert
                      • Apr 2007
                      • 5821

                      #11
                      Heya, ManWithNoName.

                      The important thing is that you are meeting new people :)

                      Comment

                      • ManWithNoName
                        New Member
                        • Aug 2007
                        • 88

                        #12
                        Originally posted by pbmods
                        Heya, ManWithNoName.

                        The important thing is that you are meeting new people :)
                        Funny, it seems that you are the only one I see everywhere ;)

                        Comment

                        • pbmods
                          Recognized Expert Expert
                          • Apr 2007
                          • 5821

                          #13
                          Originally posted by ManWithNoName
                          Funny, it seems that you are the only one I see everywhere ;)
                          Try going to the ASP forum :P

                          Comment

                          • ManWithNoName
                            New Member
                            • Aug 2007
                            • 88

                            #14
                            Originally posted by pbmods
                            Try going to the ASP forum :P
                            lol! Why do I get the feeling that your setting me up for a trap ;)

                            Comment

                            Working...