Does php have a function that is returned immediately after the script is called? What should I do?

Source: Internet
Author: User
Does php have a function that is returned immediately after the script is called? For example, a php file named a. php can be executed in about 2 minutes. Is there a function that can be executed on this file? Just wake up a. php and let it execute. the main program immediately returns to handle other things. ------ Solution ------------------ the fsockopen () function may solve your problem. qianxunniao. I does php have a function that is returned immediately after the script is called?
For example, a php file named a. php can be executed in about 2 minutes. Is there a function that can be executed on this file?

Just wake up a. php and let it execute. the main program immediately returns to handle other things.

------ Solution --------------------
The fsockopen () function may solve your problem.
Http://qianxunniao.iteye.com/blog/1243602
------ Solution --------------------
How does test get my reply?
You can also use php to call external commands to execute B. php.
------ Solution --------------------
Here is a function available in multiple environments.
But it cannot be used in your environment.
PHP code
/*** Function tenor ** starts a url, but does not wait to return * parameter $ page. the page program to be executed * returns none **/if (! Function_exists ('tenor'): function tenor ($ page) {$ host = $ _ SERVER ["HTTP_HOST"]; $ fp = fsockopen ($ host, 80, $ errno, $ errmsg); if (! $ Fp) {echo "$ errstr ($ errno)
\ N ";}else {fputs ($ fp," GET/$ page HTTP/1.0 \ nHost: $ host \ n "); fclose ($ fp ); // this line may need to be commented out} endif;
------ Solution --------------------
Php does not support multithreading, let alone the main thread and sub-thread. But there is a way to simulate this environment, the code is as follows:
Do {
? $ Mrc = curl_multi_exec ($ mh, $ active );
? } While ($ mrc = CURLM_CALL_MULTI_PERFORM );
? While ($ active and $ mrc = CURLM_ OK ){
? If (curl_multi_select ($ mh )! =-1 ){
? Do {
? $ Mrc = curl_multi_exec ($ mh, $ active );
? } While ($ mrc = CURLM_CALL_MULTI_PERFORM );
? }
? }
? It is simulated through a continuous loop,

If this method doesn't work, use the scheduled tasks of the system to regularly execute the program ~
------ Solution --------------------
For this kind of thing, use C. php only lives for the Web ..

The specific program architecture must be clearly described.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.