Jump to content

curl


zipp

Recommended Posts

Hello, here is what I am trying to do:

use curl to get info from page2.php that is running the script:

 

<?
$i=0;
while($i < 100){
$i++;
sleep(1);
echo $i." ";
    flush();
    ob_flush();
}
?>

(Thank you l0ve2hat3 : )

 

I need the page1.php to update as page2.php updates.

 

Is there any way to do this?

Link to comment
Share on other sites

Here's my interpretation.

 

You want page1.php to continually add the output of page2.php onto page1. If that's what you want, there's no "proper" way to do it with PHP alone. If you include it or even do readfile (btw, readfile will get you the code, not the result of the code) it won't update continuously. It'll just take its time, finishing the loop, before the user sees anything (unless you have output buffer off, or you're forcing the output buffer to flush, which you are). But it will NOT continue to load the rest of the page until that code is done. And my assumption is you want page2.php to run independently of page1.

 

Let me try to summarize it (in case the above is confusing): you want page1 to load completely, done, and for it to load the result of page2 somewhere into page1 continually.

 

I hope I'm not being confusing. Anyway.

 

The best way you may want to approach this is a mix of PHP and javascript/AJAX. Use AJAX to continually poll page2.php and print the result into page1.php.

Link to comment
Share on other sites

The best way you may want to approach this is a mix of PHP and javascript/AJAX. Use AJAX to continually poll page2.php and print the result into page1.php.

 

I was afraid it would be something like that. Could you point me to a good tutorial, or supply a script of something similar?

Link to comment
Share on other sites

You'll want to start ground up with Javascript and AJAX. If you're adept in PHP, javascript should come to you fairly quickly. You don't even need to take on javascript entirely to grasp AJAX. But I'd suggest it. If the page2.php you provided is all you want it to do, you can just do that in javascript without PHP at all.

 

Good PHP/AJAX tutorial:

http://www.ajaxf1.com/tutorial/ajax-php.html

 

Other references:

Javascript Tutorials:

http://www.tizag.com/javascriptT/

 

AJAX tutorials

http://www.tizag.com/ajaxTutorial/

Link to comment
Share on other sites

Very clever, theoretically that should work. What's the problem? And if you fix it, do share.

 

Although, I'm not much of a fan of iframes, but where it works, it works, no?

Link to comment
Share on other sites

I'm not a big fan of frames either, but I'm trying all my options here.

 

What i am actually making is... not sure what you would call it... it pings a server 10 times, then averages the pings to get the "average ping time"... the first ping always works... here is what it looks like

 

0.0607 seconds  <-- normal

0.0057 seconds  <-- crazzy

0.0577 seconds  <-- normal

0.0041 seconds  <-- crazzy

0.0034 seconds  <-- crazzy

 

etc...

 

So I'm completely loss on this...

 

It only stopped working when I started using iframes.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.