php基础

80 篇文章 0 订阅

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 服务器启动时读取一次。对于 CGICLI 版本,每次调用都会读取。

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.iniphp-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.想知道脚本开始执行的时刻:

使用$_SERVER[‘REQUEST_TIME’]要好于time()。

8.普通方法和静态方法谁快?

单纯方法调用普通方法比静态方法快,但调用普通方法之前需要new操作,两步操作导致调用普通方法比调用静态方法慢

9.x-powered-by头?
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,不然后面的代码会继续执行.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

anssummer

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值