How to use the PHP function to get the current running environment to determine the execution logic of tips

  • 2020-06-19 09:59:36
  • OfStack

Generally, we run apache, but some people run IIS
If we want to know what environment we're currently running in, we just need to test it with the function php_sapi_name()
Compare and judge processing
Function: php_sapi_name ();
The output under apache is "apache2handler";
The output in cgi mode is "ES18en-ES19en"
When run in command line mode, the output is "cli"



Related articles: