PHP非同步操作方法

2021-06-25 07:30:20 字數 2463 閱讀 7949

$timeout=array('asyn'=>true,'time'=>3000);//毫秒 //是否非同步

$str = http_request('post','127.0.0.1',80, $url,$getdataarr,$postdataarr,$cookiedataarr,$customheader,$timeout,$req_hdr,$res_hdr); //非同步

file_put_contents("action.txt", $str);

echo '結束';

background.php 內容測試
<?php

set_time_limit(0);

for($i=0;$i<5;$i++)

echo date('y-m-d h:i:s').'end!';

?>

以上我第乙份php工作中寫的,老闆當時說php後端傳送幾百上千份email,而且要立即返回已接受處理狀態給前端。

通過以上php**可完成非同步傳送大量eamil或其他費時操作。

PHP之檔案目錄基礎操作方法

1.檔案的屬性資訊獲取 首先檔案具有型別,在linux下邊,有block 塊裝置,如磁碟分割槽 cd rom char 以字元為輸入的裝置,如鍵盤 印表機 dir 目錄型別,目錄也是檔案的一種 fifo 命名管道,解釋是將資訊從乙個程序傳到另乙個程序 file 普通的檔案 link 鏈結,類似win...

XML操作方法

4 寫xml標記及資料,儲存為xml檔案.建立檔案流,建立xmltextwriter並設定formatting屬性 string filename textbox1.text system.io.filestream myfilestream new system.io.filestream fil...

sys class gpio 操作方法

在嵌入式裝置中對gpio的操作是最基本的操作。一般的做法是寫乙個單獨驅動程式,網上大多數的例子都是這樣的。其實linux下面有乙個通用的gpio操作介面,那就是我要介紹的 sys class gpio 方式。下面以友堅4412開發板上除錯為例子說明流程 首先,看看系統中有沒有 sys class g...