我有一个很大的问题,因为几个小时我试图运行一个在PHP中使用SETENV的项目。当他甚至尝试使用简单函数apache_getenv();
时<?php
$ret = apache_getenv("SERVER_ADDR");
echo $ret;
?>
我收到一个反馈错误消息
Fatal error: Uncaught Error: Call to undefined function apache_getenv() in /var/www/html/env.php:2 Stack trace: #0 {main} thrown in /var/www/html/env.php on line 2
使用PHP-CLI相同的错误。我的配置下面。
Apache/2.4.34 (Fedora)
PHP 7.2.15 (cli)
# apachectl -M | grep env
env_module (shared)
setenvif_module (shared)
php-fpm无法使用函数apache_getenv()。只需使用getenv()而不是apache_getenv()。
<?php
$ret = getenv("SERVER_ADDR");
echo $ret;
?>
通常没有理由使用apache_getenv()而不是getenv()。