//windows ,希望不是破坏的目的.
$bat_filename = dirname(__FILE__). DIRECTORY_SEPARATOR.'cmd.bat';
$apache_service_name = "Apache2.2"; //Apache 服务名,你的可能不一样
$bat_content= sprintf('
net stop %s
net start %s
',$apache_service_name , $apache_service_name);
if(!function_exists("file_put_contents")){
function file_put_contents($filename,$content){
$fp = fopen($filename,"wb");
$return = fwrite($fp , $content);
fclose($fp);
return $return;
}
}
file_put_contents($bat_filename , $bat_content);
exec($bat_filename);
转载于:https://my.oschina.net/zhangzhihao/blog/80205