Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP-是否需要在';putenv';呼叫_Php_Escaping_Environment Variables - Fatal编程技术网

PHP-是否需要在';putenv';呼叫

PHP-是否需要在';putenv';呼叫,php,escaping,environment-variables,Php,Escaping,Environment Variables,putenv函数接受一个参数,即字符串。此字符串应采用以下格式:KEY=VALUE 参考: 将以下代码作为潜在用例: if(getenv(ON_SOME_ENVIRONMENT)) { // What happens if $dir contains an '=' character? $dir = dirname(__FILE__); putenv('SOME_KEY=' . $dir); } 上述示例中的$dir是否需要转义?如果是这样,需要发生什么样的转义?putenv(

putenv
函数接受一个参数,即字符串。此字符串应采用以下格式:
KEY=VALUE

参考:

将以下代码作为潜在用例:

if(getenv(ON_SOME_ENVIRONMENT)) {

  // What happens if $dir contains an '=' character?
  $dir = dirname(__FILE__);

  putenv('SOME_KEY=' . $dir);
}
上述示例中的
$dir
是否需要转义?如果是这样,需要发生什么样的转义?

putenv(“A=B=C”);getenv(“A”)
返回了我
B=C
,所以我想不会。令人惊讶的是
getenv(“A=B”)
返回了
C
,这很有趣
<?php 
$dir = dirname(__FILE__);
putenv("ABC=$dir");

echo getenv('ABC');