php curl
So then, would it be sufficient to just have page1.php use curl to grab the page information from page2.php and echo it as it's own page? If that were the case, why don't you just use include(page2.php); in page1.php? It seems kinda impractical to use cURL to use it to update page1.php with page2.php's inormation constantly because it will only work while the script is being executed on the server. What exactly do you need, do you need certain information to be echoed on page1.php from page2.php or just replicate it?
Ah, if it's remote then your best bet would probably be to use readfile(). But, it shouldn't be too terribly difficult to use curl either I guess, it would seem simple enough as doing something like:
<?php
$i = 1;
while($i > 0){
$url=("page2.php");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$result = curl_exec($ch);
curl_close($ch);
echo($result);
$i++;
}
?>
mirite?? :p
[edit] Oops forgot a line [/edit]
Feralas wrote: That script will wait until the script on page2 finishes, then it loads it onto page1, which isn't quite what I want done… I'm thinking it cant be done with curl.
edit Looks like the only way to do it is with javascript/ajax… that shall be a pain in the rear.
Erm..no it won't. It is an infinite loop where it constantly gets the HTML data from page2.php, stores it as $result and echoes the HTML and/or javascript onto the page. It does not wait for a page to stop loading to update etc..It just basically keeps the page updated with a loop of curl queries and doesn't stop while the PHP page is loaded. It won't just automatically update it's self invisibly, the PHP must be executed though. I'm not at all saying that was the easiest/most effective or efficient way to do it in fact, it's not. But meh, it can be done with PHP probably easier than javascript or at least more efficiently.