473,388 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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?
Sep 2 '07 #1
13 2688
You could fprintf() it somewhere instead of echoing...
@see: http://www.php.net/manual/en/function.fprintf.php
Sep 2 '07 #2
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)).
Sep 2 '07 #3
... I think that I'm looking for the PHP output buffer file, is this correct?
Sep 2 '07 #4
pbmods
5,821 Expert 4TB
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?
Sep 2 '07 #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?
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...
Sep 2 '07 #6
pbmods
5,821 Expert 4TB
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:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     /***************
  3.     *
  4.     *    Start output buffering.
  5.     */
  6.     ob_start();
  7.  
  8.     /***************
  9.     *
  10.     *    This won't get output.
  11.     */
  12.     echo 'Hello, World!';
  13.  
  14.     /***************
  15.     *
  16.     *    Capture buffered output.
  17.     */
  18.     $str = ob_get_contents();
  19.  
  20.     /***************
  21.     *
  22.     *    Clear the buffer.  This also turns off output buffering.
  23.     */
  24.     ob_end_clean();
  25.  
  26.     /***************
  27.     *
  28.     *    Outputs:
  29.     *    Hello, ManWithNoName!
  30.     */
  31.     echo str_replace('World', 'ManWithNoName', $str);
  32. ?>
  33.  
Sep 2 '07 #7
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!
Sep 2 '07 #8
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.
Sep 3 '07 #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.
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!
Sep 4 '07 #10
pbmods
5,821 Expert 4TB
Heya, ManWithNoName.

The important thing is that you are meeting new people :)
Sep 4 '07 #11
Heya, ManWithNoName.

The important thing is that you are meeting new people :)
Funny, it seems that you are the only one I see everywhere ;)
Sep 4 '07 #12
pbmods
5,821 Expert 4TB
Funny, it seems that you are the only one I see everywhere ;)
Try going to the ASP forum :P
Sep 4 '07 #13
Try going to the ASP forum :P
lol! Why do I get the feeling that your setting me up for a trap ;)
Sep 5 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philipp Lenssen | last post by:
I read about a PHP5 function loadHTMLFile*, which I could use to grab any URL on the Web -- say, http://www.cnn.com tag soup -- and apply XPath, like "//body/h2/*". Is this for real or does it just...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
2
by: mouseit101 | last post by:
Hi, I'm writing a script that would (hopefully) search google images for whatever, and then return a list of URLs for the image. Right now I have: $dom = new DomDocument(); $url =...
9
by: loretta | last post by:
This code is just reading html and printing , eventually I want to modify the html. However, the original html contains javascript and the output html contains tags not in the original. $url =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.