gpt4 book ai didi

javascript - PHP 脚本未在服务器 shell 上显示正确的数据

转载 作者:行者123 更新时间:2023-11-28 05:40:11 25 4
gpt4 key购买 nike

我想运行这个脚本:

<?php
$file = file_get_contents('data.json');
echo ($file);
unset($file);
exit(0);
?>

如果我在 JS 中通过 ajax 访问此脚本,则没有问题,但如果我使用 php script.phpphp -f script.php 在我的服务器 shell 上运行此脚本code> 始终显示此 JSON 字符串的旧版本。通过 ajax,我总是从该脚本收到最新的数据。

最后,我需要将此脚本包含在另一个 php 脚本中,该脚本运行一个循环来检测更改。这也没有收到最新的数据。

最佳答案

试试这个:

<?php
$file = file_get_contents( __DIR__ . DIRECTORY_SEPARATOR .'data.json');
echo ($file);
unset($file);
exit(0);
?>

data.json 应与您的 php 文件位于同一目录中。

关于javascript - PHP 脚本未在服务器 shell 上显示正确的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38982849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com