here's the php info page for my host:
http://picnictoimpeach.us/check_info.php5
i don't have shell access on my shared hosting service, so i cannot
use "popen". at least, popen is not working for me here. am i doing
something wrong?
PHP Code:
<?php
$myhandle = pclose(popen("http://picnictoimpeach.us/remote.php5"));
?>
Asynchronous PHP WITHOUT shelling?
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
popen() is for opening processes, not remote pages.
fopen(), file_get_contents(), file() are more general for doing these sorts of things.
However you may need to use fsockopen() or cURL.
fopen(), file_get_contents(), file() are more general for doing these sorts of things.
However you may need to use fsockopen() or cURL.
Curl Not Asynchronous Enough
My calling page needs php to return to it immediately after the print statement, but it doesn't. It waits until the curl code completes.
how can i exit this php script immediately after executing the external php, without waiting for the external process to complete? should i use fopen or something else?
how can i exit this php script immediately after executing the external php, without waiting for the external process to complete? should i use fopen or something else?
Code: Select all
<?php
print file_get_contents("http://picnictoimpeach.us/videos/playlist.xml");
// create cURL resource
$ch1 = curl_init();
// set URL and other appropriate options
curl_setopt($ch1, CURLOPT_URL, "http://picnictoimpeach.us/remote.php5");
curl_setopt($ch1, CURLOPT_HEADER, 0);
//create the multiple cURL handle
$mh = curl_multi_init();
//add the handle
curl_multi_add_handle($mh,$ch1);
$running=null;
//execute the handle
do {
curl_multi_exec($mh,$running);
} while ($running > 0);
//close the handle
curl_multi_remove_handle($mh,$ch1);
curl_multi_close($mh);
?>Not Synchronous Enough
this is not asynchronous enough either
Code: Select all
<?php
print file_get_contents("http://picnictoimpeach.us/videos/playlist.xml");
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://picnictoimpeach.us/remote.php5");
curl_exec ($curl);
curl_close ($curl);
?>variable scope?
i'm wondering if the problem is that $curl is a local variable handle on the curl process, and that once this script exits, $curl dies because it goes out of scope. is that true?
Since php isn't a multi-threaded language, I believe you have to wait until the curl commands have finished executing. Unless you feel like working in a javascript or image hack to pipe the process to another stream.
(I could be talking out of my butt, here
This isn't exactly my area of expertise)
(I could be talking out of my butt, here
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
If you want it asynchronous, you will have to shunt it to a separate process/thread. PHP doesn't support it natively, but that doesn't preclude you from starting another instance of PHP (via command line) and redirecting output.
See examples on system(), shell_exec() and exec(). There was at least one on pushing a call to the background in them that I recall.
See examples on system(), shell_exec() and exec(). There was at least one on pushing a call to the background in them that I recall.
Re: Curl Not Asynchronous Enough
ahh not async then, what you need to do is return the print before executing curl.. thus output buffering as below should do what you want (the client will see the output of print, before cURL has run!johnywhy wrote:My calling page needs php to return to it immediately after the print statement, but it doesn't. It waits until the curl code completes.
how can i exit this php script immediately after executing the external php, without waiting for the external process to complete? should i use fopen or something else?
Code: Select all
<?php
ob_start();
print file_get_contents("http://picnictoimpeach.us/videos/playlist.xml");
ob_flush()
flush();
ob_end_clean();
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://picnictoimpeach.us/remote.php5");
curl_exec ($curl);
curl_close ($curl);
?>