1

I have a big problem because for several hours I am trying to run a project that uses SetENV in PHP. When he even tries to use a simple function apache_getenv();

<?php
$ret = apache_getenv("SERVER_ADDR");
echo $ret;
?>

I receive a feedback error message

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

Using php-cli the same error. My configuration below.

Apache/2.4.34 (Fedora)
PHP 7.2.15 (cli)

# apachectl -M | grep env
env_module (shared)
setenvif_module (shared)
erdys
  • 39
  • 5

1 Answers1

0

The function apache_getenv() is not available with PHP-FPM. Simply use getenv() instead of apache_getenv().

<?php
$ret = getenv("SERVER_ADDR");
echo $ret;
?>

There is usually no reason to use apache_getenv() instead of getenv() now.

HaWei
  • 41
  • 5