我在 Wordpress 插件中有一个脚本,我正在尝试使用fwrite()
.
我的代码是这样的:
$log_url = __DIR__ . '/logs/update-email-publish-tasks/' . date("n.j.Y") . '.txt';
$logfile = fopen($log_url, "w");
fwrite($logfile, 'Starting tasks at ' . date("H.i.s") . "\n");
//A bunch of code that logs stuff;
fwrite($logfile, "\n" . 'Finished at !' . date("H.i.s") . "\n");
fclose($logfile);
这在本地运行良好,但不适用于生产。我想知道我是否需要使用其他东西__DIR__
?我也试过WP_CONTENT_DIR
了,没有用。
FWIW 我在万神殿主持制作。