<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                win32service擴展是Windows特定的擴展,允許PHP與服務控制管理器進行通信以啟動,停止,注冊和注銷服務,甚至允許您的PHP腳本作為服務運行 [https://pecl.php.net/package/win32service](https://pecl.php.net/package/win32service) * [預定義常量](https://www.php.net/manual/en/win32service.constants.php) * [Win32Service服務類型位掩碼](https://www.php.net/manual/en/win32service.constants.servicetype.php) * [Win32Service服務狀態常數](https://www.php.net/manual/en/win32service.constants.servicestatus.php) * [Win32Service服務控制消息常量](https://www.php.net/manual/en/win32service.constants.servicecontrol.php) * [Win32Service服務控制消息接受的位掩碼](https://www.php.net/manual/en/win32service.constants.controlsaccepted.php) * [Win32Service服務啟動類型常量](https://www.php.net/manual/en/win32service.constants.servicestarttype.php) * [Win32Service服務錯誤控制常數](https://www.php.net/manual/en/win32service.constants.errorcontrol.php) * [Win32Service服務標志常量](https://www.php.net/manual/en/win32service.constants.serviceflag.php) * [Win32錯誤代碼](https://www.php.net/manual/en/win32service.constants.errors.php) * [Win32基本優先級類](https://www.php.net/manual/en/win32service.constants.basepriorities.php) * [Win32恢復操作](https://www.php.net/manual/en/win32service.constants.recovery-action.php) * [Win32服務信息](https://www.php.net/manual/en/win32service.constants.serviceinfos.php) * [例子](https://www.php.net/manual/en/win32service.examples.php) * [win32service函數](https://www.php.net/manual/en/ref.win32service.php) * [win32\_continue\_service](https://www.php.net/manual/en/function.win32-continue-service.php)—恢復暫停的服務 * [win32\_create\_service](https://www.php.net/manual/en/function.win32-create-service.php)—在SCM數據庫中創建新的服務條目 * [win32\_delete\_service](https://www.php.net/manual/en/function.win32-delete-service.php)—從SCM數據庫中刪除服務條目 * [win32\_get\_last\_control\_message](https://www.php.net/manual/en/function.win32-get-last-control-message.php)—返回發送到該服務的最后一條控制消息 * [win32\_pause\_service](https://www.php.net/manual/en/function.win32-pause-service.php)—暫停服務 * [win32\_query\_service\_status](https://www.php.net/manual/en/function.win32-query-service-status.php)—查詢服務狀態 * [win32\_send\_custom\_control](https://www.php.net/manual/en/function.win32-send-custom-control.php)—將自定義控件發送到服務 * [win32\_set\_service\_exit\_code](https://www.php.net/manual/en/function.win32-set-service-exit-code.php)—定義或返回當前正在運行的服務的退出代碼 * [win32\_set\_service\_exit\_mode](https://www.php.net/manual/en/function.win32-set-service-exit-mode.php)—定義或返回當前正在運行的服務的退出模式 * [win32\_set\_service\_status](https://www.php.net/manual/en/function.win32-set-service-status.php)—更新服務狀態 * [win32\_start\_service\_ctrl\_dispatcher](https://www.php.net/manual/en/function.win32-start-service-ctrl-dispatcher.php)—向SCM注冊腳本,以便它可以使用給定名稱充當服務 * [win32\_start\_service](https://www.php.net/manual/en/function.win32-start-service.php)—啟動服務 * [win32\_stop\_service](https://www.php.net/manual/en/function.win32-stop-service.php)—停止服務 Windows 服務(即,以前的 NT 服務)使您能夠創建在它們自己的 Windows 會話中可長時間運行的可執行應用程序 。 這些服務可以在計算機啟動時自動啟動,可以暫停和重新啟動而且不顯示任何用戶界面。這使服務非常適合在服務器上使用,或任何時候,為了不影響在同一臺計算 機上工作的其他用戶,需要長時間運行功能時使用。還可以在不同于登錄用戶的特定用戶帳戶或默認計算機帳戶的安全上下文中運行服務 簡單的說就是可以長時間、自動運行在Windows上的PHP程序。 問:這對我來說重要嗎? 有什么用? ?哈哈哈!有了這個,我們就可以做更多的事了。如:定期執行一個PHP任務、自動更新數據?....等等。 如何實現? 必須有一臺 Windows服務器 或者Windows PC機 必須安裝得有PHP運行環境 必須在PHP 的安裝目錄的\\ext\\下有這個 php\_win32service.dll文件 必須有php.ini文件里面開啟 ?extension=php\_win32service.dll 這個選項 如果你運行不起來(請看一哈上面的說明哦)最重要代碼來了,如下 ``` <?php /** * 利用PHP安裝windows自動運行的服務 * $Id: WinService.class.php * $winService = new WinService(); * $winService->install(); */ class WinService { //服務名稱 var $name = 'PHP Service'; //定義服務名稱 var $info_name = "Exsample PHP Service"; //定義php.exe存放路徑 var $path = "C:\\wamp\\php\\php.exe"; //定義所要執行的程序 var $params = "D:\\localhost\\Service\\win32_service.php"; //定義程序分隔執行時間,單位:秒 var $sleep = 5; private function __construct($name = '', $infoName = '', $param = '') { $this->name = $name; $this->info_name = $infoName; $this->params = $param; } public function install() { /* 注冊服務 */ $x = win32_create_service(array( 'service' => $this->name, 'display' => $this->info_name, 'path' => $this->path, 'params' => $this->params, )); /* 啟動服務 */ win32_start_service($this->name); if ($x !== true) { die ('服務創建失敗!'); } else { die ('服務創建成功!'); } } public function uninstall() { /* 移除服務 */ $removeService = win32_delete_service($this->name); switch ($removeService) { case 1060: die ('服務不存在!'); break; case 1072: die ('服務不能被正常移除! '); break; case 0: die ('服務已被成功移除!'); break; default : die (); break; } } public function restart() { /* 重啟服務 */ $svcStatus = win32_query_service_status($this->name); if ($svcStatus == 1060) { echo "服務[" . $this->name . "]未被安裝,請先安裝"; } else { if ($svcStatus['CurrentState'] == 1) { $s = win32_start_service($this->name); if ($s != 0) { echo "服務無法被啟動,請重試! "; } else { echo "服務已啟動! "; } } else { $s = win32_stop_service($this->name); if ($s != 0) { echo " 服務正在執行,請重試! "; } else { $s = win32_start_service($this->name); if ($s != 0) { echo "服務無法被啟動,請重試! "; } else { echo "服務已啟動! "; } } } } } public function start() { $s = win32_start_service($this->name); if ($s != 0) { echo " 服務正在運行中! "; } else { echo " 服務已啟動! "; } } public function stop() { $s = win32_stop_service($this->name); if ($s != 0) { echo " 服務未啟動! "; } else { echo " 服務已停止! "; } } } ?> ``` win32_service.php ``` <?php //檢測服務是否存在 if (!win32_start_service_ctrl_dispatcher("PHP Service")) { die("沒有發現正在運行的 [ "PHP Service" ] 服務"); } win32_set_service_status(WIN32_SERVICE_START_PENDING); win32_set_service_status(WIN32_SERVICE_RUNNING); //如果運行中 while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) { //寫入文件 for ($i = 1; $i <= 1; $i++) { $b_file_path = "D:\\localhost\\test.txt"; $f = fopen($b_file_path, 'a+'); $msg = 'Dernier backup correctement:' . date('y/m/d h:i:s'); fwrite($f, $msg . "\r\n"); fclose($f); sleep(1); } } ?> ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看