您可以使用SAPI
> php_sapi_name
– 返回Web服务器和PHP之间的接口类型
Returns the interface type,as a lowercase string.
Although not exhaustive,the possible return values include aolserver,apache,apache2filter,apache2handler,caudium,cgi (until PHP 5.3),cgi-fcgi,cli,continuity,embed,isapi,litespeed,milter,nsapi,phttpd,pi3web,roxen,thttpd,tux,and webjames.
对于状态和提供的请求数量,您可能希望使用exec或system.