PHP系統(tǒng)命令函數(shù)使用分析
更新時(shí)間:2013年07月05日 08:55:39 作者:
本篇文章是對(duì)PHP中系統(tǒng)命令函數(shù)的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
復(fù)制代碼 代碼如下:
function execute($cmd) {
$res = '';
if ($cmd) {
if(function_exists('system')) {
@ob_start();
@system($cmd);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cmd);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('shell_exec')) {
$res = @shell_exec($cmd);
} elseif(function_exists('exec')) {
@exec($cmd,$res);
$res = join(“\n",$res);
} elseif(@is_resource($f = @popen($cmd,"r"))) {
$res = '';
while(!@feof($f)) {
$res .= @fread($f,1024);
}
@pclose($f);
}
}
return $res;
}
您可能感興趣的文章:
相關(guān)文章
PHP操作Postgresql封裝類(lèi)與應(yīng)用完整實(shí)例
這篇文章主要介紹了PHP操作Postgresql封裝類(lèi),結(jié)合實(shí)例形式分析了php針對(duì)Postgresql數(shù)據(jù)庫(kù)常見(jiàn)的連接、查詢、統(tǒng)計(jì)等操作封裝技巧與使用方法,需要的朋友可以參考下2018-04-04WordPress開(kāi)發(fā)中用于標(biāo)題顯示的相關(guān)函數(shù)使用解析
這篇文章主要介紹了WordPress開(kāi)發(fā)中用于標(biāo)題顯示的相關(guān)函數(shù)使用解析,講解了single_cat_title函數(shù)和get_the_title函數(shù)和the_title函數(shù)的用法,需要的朋友可以參考下2016-01-01了解Joomla 這款來(lái)自國(guó)外的php網(wǎng)站管理系統(tǒng)
joomla在國(guó)外很熱,就連臺(tái)灣都有不少站使用joomla,國(guó)內(nèi)就對(duì)joomla缺乏了解。大多都使用dedecms或者phpcms等。在這四個(gè)月來(lái)一直在學(xué)習(xí)joomla,覺(jué)得用它來(lái)建站很方便。2010-03-03php在數(shù)據(jù)庫(kù)抽象層簡(jiǎn)單使用PDO的方法
這篇文章主要介紹了php在數(shù)據(jù)庫(kù)抽象層簡(jiǎn)單使用PDO的方法,以PDO針對(duì)數(shù)據(jù)庫(kù)的連接、插入、查詢等操作為例分析了PDO操作數(shù)據(jù)庫(kù)的相關(guān)技巧,需要的朋友可以參考下2015-11-11詳解WordPress開(kāi)發(fā)中用于獲取分類(lèi)及子頁(yè)面的函數(shù)用法
這篇文章主要介紹了WordPress開(kāi)發(fā)中g(shù)et_category與get_children函數(shù)的用法,分別用于獲取分類(lèi)和獲取子頁(yè)面等功能,需要的朋友可以參考下2016-01-01收集的PHP中與數(shù)組相關(guān)的函數(shù)
收集的PHP中與數(shù)組相關(guān)的函數(shù)...2007-03-03