windows下php重启apache

<?php
//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);

你可能感兴趣的:(windows下php重启apache)