php cli 下怎么给$_SERVER 增加变量

WBOY
Release: 2016-06-06 20:32:02
Original
1060 people have browsed it

非cli 而且用nginx 的时候
可以用 fastcgi_param 给 $_SERVER 增加属性;

但在cli 模式下怎么做呢

回复内容:

非cli 而且用nginx 的时候
可以用 fastcgi_param 给 $_SERVER 增加属性;

但在cli 模式下怎么做呢

$_SERVER是个变量,变量就意味着你可以轻松修改它……

<code>php</code><code>$_SERVER['ooxx'] = '囧'; //想了想还是给个例子吧
</code>
Copy after login

环境变量会出现在$_SERVER中,所以直接修改环境变量就行

<code>$ YOUR_VARIABLE=here php -r 'print_r($_SERVER);'|grep here
    [YOUR_VARIABLE] => here
$ export ANOTHER_VAR=this
$ php -r 'print_r($_SERVER);'|grep this
    [ANOTHER_VAR] => this
</code>
Copy after login
Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template