php - PHP __DIR__ 在本地工作但不在生产环境中
问题描述
我在 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 我在万神殿主持制作。
解决方案
推荐阅读
- security - 您如何安全地实施本地失效/清除?
- python - AttributeError: 'Token' 对象在运行 jupyter notebook 时没有属性 'test'
- javascript - 如何在 chrome 扩展中使用谷歌翻译(重写 Tampermonkey)
- bash - 如何在机器上的所有 git 存储库上运行命令?
- r - 嵌套函数:Arrange() 和 desc()
- javascript - 从反应中选择的下拉菜单中获取价值
- bash - “cat > filename << EOF”和“cat << EOF > filename”是否等效?
- java - 如何仅与一个起始整数平方?
- flutter - Flutter:如何获取PC ipv4
- python-3.x - Scipy.optimize fmin 不优化四轴飞行器的功能