php - 消息:file_get_contents(sso.json):无法打开流:没有这样的文件或目录
问题描述
我正在尝试手动从 JSON 文件中获取数据,而不是从 URL 中获取数据。我使用函数file_get_contents。我得到了错误:
消息:file_get_contents(sso.json):无法打开流:没有这样的文件或目录
即使路径是正确的。这是我的结构项目:
-> kalenderkerja
-> application
-> controllers
-> agendakerja
Kalender.php
sso.json
-> assets
-> ...
这是我在文件Kalender.php中的函数user()中的代码
public function user() {
$url = 'sso.json';
$data = file_get_contents($url);
$characters = json_decode($data, true);
echo $characters['name'];
}
我在浏览器localhost/kalenderkerja/agendakerja/kalender/user中调用控制器 ,我得到了这个错误:
解决方案
推荐阅读
- matlab - 在 MATLAB 中使用 FFT 并在高斯上正确重新缩放
- java - ListView 未显示 Wifi 列表数组
- python - 子进程的 Python 替代方法
- android - Android Studio 可以很好地构建应用程序,但它在模拟器/设备上崩溃
- c++ - 如何将函数集合传递给客户端类以将它们用作客户端类本身的成员?
- python - 使用 x 轴格式绘制区域图
- java - Java 中的异步文件 NIO 有什么好处?
- excel - Excel 数据透视表列出重复条目(不计算它们)
- html - Angular 8,Typescript - 单击按钮以显示那些无效/必填字段后如何获取表单中所有无效元素的列表
- python - Python:char的位置= word[i]