Home > php教程 > php手册 > body text

判断php的运行环境

WBOY
Release: 2016-06-06 19:52:09
Original
1900 people have browsed it

阅读ci代码过程中发现,处理URI会根据php的运行环境进行不用处理。 那么如何判断php的运行环境呢? 我们一般情况下,都是在apache下面运行我们的php程序,当然也有些人是用IIS环境的 我们要是想知道我们目前运行的环境是什么的话,那我们可以用函数php_sapi_

阅读ci代码过程中发现,处理URI会根据php的运行环境进行不用处理。

那么如何判断php的运行环境呢?

我们一般情况下,都是在apache下面运行我们的php程序,当然也有些人是用IIS环境的
我们要是想知道我们目前运行的环境是什么的话,那我们可以用函数php_sapi_name()来测试
代码:

 

echo php_sapi_name();

?>

在apache环境下面输出的结果是“apache2handler”;
在cgi模式下输出的结果是“cgi-fcgi”
要是在命令行模式下面运行的话,那么输出的结果是:”cli”
依据这个内容我们可以判断当前运行的环境是什么!
那么在命令行下怎么运行呢?
如下:
进入DOS 进入php.exe文件的地址 如我的是:d:/wamp/bin/php/php5.3.3/
然后输入php.exe “文件的绝对路径” 如:>php.exe d:/wamp/www/info.php
既可以了。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!