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

后端 未结 9 1706
借酒劲吻你
借酒劲吻你 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:30

    define('DOCROOT', substr(str_replace(pathinfo(__FILE__, PATHINFO_BASENAME), '', __FILE__), 0, -1));
    

    This will get you the same data as $_SERVER['DOCUMENT_ROOT'] for cronjobs.

提交回复
热议问题