1.PHP中的$_ENV为空:
$_ENV会为空,其原因通常是php的配置文件php.ini的配置项为:variables_order = "GPCS"。要想让$_ENV的值不为空,那么variables_order的值应该加上一个大写字母“E”, 即:variables_order = "EGPCS"。
2.在wamp环境下,配置了variables_order=EGPCS,但php -r "var_dump($_ENV);" 老是输出为空?
php cli 没有指定配置文件时,默认加载php.exe目录下的ini配置文件,所以无效.
php -c xxxxx -r "cmd"
3.在cli中怎么查看命令行加载的配置文件?
在web中通过phpinfo()来查看,在cli中也有同样的命令:
php - i | grep php.ini
或者最简单的:
php --ini // Show configuration file
4.rewrite_tags trans_id加载哪些链接后面?
; url_rewriter.tags; Default Value: "a=href,area=href,frame=src,form=,fieldset="
; Development Value: "a=href,area=href,frame=src,input=src,form=fakeentry"
; Production Value: "a=href,area=href,frame=src,input=src,form=fakeentry"
5.apache加载php.ini文件的路径索索过程?
配置文件(PHP 3 中是 php3.ini,自 PHP 4 起是 php.ini)在 PHP 启动时被读取。对于服务器模块版本的 PHP,仅在 web 服务器启动时读取一次。对于 CGI 和 CLI 版本,每次调用都会读取。
php.ini 的搜索路径如下(按顺序):
-
SAPI 模块所指定的位置(Apache 2 中的 PHPIniDir 指令,CGI 和 CLI 中的-c 命令行选项,NSAPI 中的php_ini 参数,THTTPD 中的PHP_INI_PATH 环境变量)
-
HKEY_LOCAL_MACHINE\SOFTWARE\PHP\IniFilePath(Windows 注册表位置)
-
PHPRC 环境变量
-
当前工作目录(对于 CLI)
-
web 服务器目录(对于 SAPI 模块)或 PHP 所在目录(Windows 下其它情况)
-
Windows 目录(C:\windows 或 C:\winnt),或 --with-config-file-path 编译时选项指定的位置
如果存在 php-SAPI.ini(SAPI 是当前所用的 SAPI 名称,因此实际文件名为php-cli.ini 或php-apache.ini 等),则会用它替代php.ini。SAPI 的名称可以用php_sapi_name() 来测定。
6.php数组中加引号和不加引号访问:
$arr = array('a'=>'one', 'b'=>'two');
define('a', 'b'); //定义常量 a
echo $arr[a];
没有加引号,会将a当做一个const,结果输出了另外的值.如果没有define('a','b'),则默认是 define('a','a'),即访问a下标.
7.想知道脚本开始执行的时刻:
8.普通方法和静态方法谁快?
9.x-powered-by头? X-Powered-By: PHP/5.1.2-1+b1…
X-Powered-By: PHP/5.1.2-1+b1…
Let’s see how we can disable it. In order to prevent PHP from exposing the fact that it is installed on the server, by adding its signature to the web server header we need to locate in php.ini the variableexpose_php
and turn it off
.
By default expose_php
is set to On.
In your php.ini (based on your Linux distribution this can be found in various places, like /etc/php.ini, /etc/php5/apache2/php.ini, etc.) locate the line containing expose_php On
and set it to Off:
expose_php = Off
After making this change PHP will no longer add it’s signature to the web server header. Doing this, will not make your server more secure… it will just prevent remote hosts to easily see that you have PHP installed on the system and what version you are running.
10.header 302后,需要exit,不然后面的代码会继续执行.