Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我正在使用的代码,是否足以确保脚本只能作为 cron 作业运行?它确实有效,但也许我错过了一些东西。
if (php_sapi_name() !== 'cli') { die("You are not allwod here"); }
是的,这会奏效。我还要确保脚本在根目录之外。