$_SERVER['DOCUMENT_ROOT'] does not work in the php script running through cron

后端 未结 9 1666
借酒劲吻你
借酒劲吻你 2020-12-08 04:35

I use $_SERVER[\'DOCUMENT_ROOT\'].\"/lib/sft_required.php\"; to include the \'sft_required\' file in a PHP script. When I run this file using browser, it works fine but whe

9条回答
  •  醉梦人生
    2020-12-08 05:20

    I answered a similar question here. As people have mentioned, the superglobal $_SERVER isn't defined in CLI situations. In the link is a (so far) foolproof method for obtaining the DOCUMENT_ROOT location. Hope it proves useful.

提交回复
热议问题