0

I get this error:

Call to undefined function apache_getenv()

I see suggestions to just switch to getenv(), but I don't see why I should have to since the manual implies it should be available for PHP 8. I have followed these instructions to find that it is not listed in the php.ini disabled functions.

I have tried with SELinux disabled, same problem. What gives?

One thing that I read in a comment is that the server API displayed by phpinfo() is not Apache, but rather FPM/FastCGI. But the manual doesn't say anything about this requirement so I'd prefer to continue to use FPM/FastCGI unless I need to change it.

enter image description here

Any ideas about what is wrong here?

raw-bin hood
  • 5,839
  • 6
  • 31
  • 45
  • 2
    The function only exists if you're using mod_php under apache. Use `$_SERVER` instead, it's SAPI-agnostic. – Sammitch Aug 04 '23 at 23:16

1 Answers1

1

From the "Introduction" section of the Apache functions documentation:

These functions are only available when running PHP as an Apache module.

Your server API is PHP-FPM rather than mod_php, thus the functions are unavailable. This makes sense, because PHP-FPM does not integrate with Apache HTTP Server, it merely receives requests through a socket and sends response back.

I don't know about your exact use case, but $_SERVER superglobal array tends to be the most compatible way to fetch information about your environment.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360