欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          一起看看PHP執(zhí)行普通shell命令流程

          一起看看PHP執(zhí)行普通shell命令流程

          【相關(guān)學(xué)習(xí)推薦:php圖文教程】

          這里演示一些普通的shell命令

            php執(zhí)行shell命令,可以使用下面幾個(gè)函數(shù):

          string system ( string $command [, int &$return_var ] )
          string exec ( string $command [, array &$output [, int &$return_var ]] )
          void passthru ( string $command [, int &$return_var ] )

            注意的是:這三個(gè)函數(shù)在默認(rèn)的情況下,都是被禁止了的,如果要使用這幾個(gè)函數(shù),就要先修改php的配置文件php.ini,查找關(guān)鍵字disable_functions,將這一項(xiàng)中的這幾個(gè)函數(shù)名刪除掉,然后注意重啟apache。

            首先看一下system()和passthru()兩個(gè)功能類似,可以互換:

          <?php   $shell = "ls -la";   echo "<pre>";   system($shell, $status);   echo "</pre>";   //注意shell命令的執(zhí)行結(jié)果和執(zhí)行返回的狀態(tài)值的對應(yīng)關(guān)系   $shell = "<font color='red'>$shell</font>";   if( $status ){     echo "shell命令{$shell}執(zhí)行失敗";   } else {     echo "shell命令{$shell}成功執(zhí)行";   } ?>

            執(zhí)行結(jié)果如下:

          一起看看PHP執(zhí)行普通shell命令流程  

            注意,system()會將shell命令執(zhí)行之后,立馬顯示結(jié)果,這一點(diǎn)會比較不方便,因?yàn)槲覀冇袝r(shí)候不需要結(jié)果立馬輸出,甚至不需要輸出,于是可以用到exec()

              exec()的使用示例:

          <?php   $shell = "ls -la";   exec($shell, $result, $status);   $shell = "<font color='red'>$shell</font>";   echo "<pre>";   if( $status ){     echo "shell命令{$shell}執(zhí)行失敗";   } else {     echo "shell命令{$shell}成功執(zhí)行, 結(jié)果如下<hr>";     print_r( $result );   }   echo "</pre>"; ?>

            運(yùn)行結(jié)果如下:

          一起看看PHP執(zhí)行普通shell命令流程

          相關(guān)學(xué)習(xí)推薦:php編程(視頻)

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號