Re: [請益] PHP有沒有辦法送出請求後,不等待回應쐠…
POSIX的platform可以用pcntl_fork(),
http://tw2.php.net/manual/en/function.pcntl-fork.php
要注意要找機會 wait 或 waitpid, 不然 child exit會變成zombie process.
複製sample code:
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} else if ($pid) {
// we are the parent
pcntl_wait($status); //Protect against Zombie children
} else {
// we are the child
}
※ 引述《asika32764 (飛鳥 Asika)》之銘言:
: 最近想再執行網頁程式的時候,
: call一些網站頁面、圖片、或是伺服器上的檔案執行工作。
: 希望能讓伺服器繼續背景執行,但是不要鎖住瀏覽器。
: 可是我發現無論用 file_get_contents()等內建函式,
: 還是用system()與exec() call主機功能運行,都還是會在等待回應的時間
: 鎖著瀏覽器無法繼續。
: 想請問PHP有辦法避開等待回應的時間繼續執行嗎?
: 類似AJAX這樣,真的不行就得要很蠢的用JS來做了...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.135.251.162
推
09/30 11:07, , 1F
09/30 11:07, 1F
→
09/30 11:08, , 2F
09/30 11:08, 2F
PHP 近期熱門文章
PTT數位生活區 即時熱門文章
125
129