- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试在 000webhosting 上创建一个非常简单的 Web 应用程序,但是当我尝试实现它时:
<?php
include_once("JSON.php");
$json = new Services_JSON();
$link = mysql_pconnect("******", "******", "******") or die("Could not connect");
mysql_select_db("******") or die("Could not select database");
$arr = array();
$rs = mysql_query("SELECT * FROM users");
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
Echo $json->encode($arr);
?>
但是我收到了这个警告/错误。你能帮帮我吗?
Warning: include_once(JSON.php) [function.include-once]: failed to open stream: No such file or directory in /home/a1622045/public_html/index.php on line 3
Warning: include_once() [function.include]: Failed opening 'JSON.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a1622045/public_html/index.php on line 3
Fatal error: Class 'Services_JSON' not found in /home/a1622045/public_html/index.php on line 4
最佳答案
改变这个:
Echo $json->encode($arr);
为此:
echo json_encode($arr);
并删除这个:
include_once("JSON.php");
$json = new Services_JSON();
您正在处理的程序使用旧的 PEAR 库,它将 JSON 对象表示法转换为 PHP 数组,反之亦然。然而,多年来 PHP 已经能够在 native 执行此操作,因此您的代码依赖于它不需要的依赖项。
我也将 Echo
切换为 echo
- PHP 关键字可以使用大小写混合格式,但最好将它们写成小写形式,因为根据手册。
关于php - fatal error : Class 'Services_JSON' not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20771532/
我尝试在 000webhosting 上创建一个非常简单的 Web 应用程序,但是当我尝试实现它时: encode($arr); ?> 但是我收到了这个警告/错误。你能帮帮我吗? Warning: i
我正在学校为我的数据挖掘类(class)做一个项目,我想使用 stackoverflow API 来获取原始数据。我正在看一个关于使用 PHP 访问它的小介绍教程,但第一个代码示例根本不起作用。罪魁祸
我是一名优秀的程序员,十分优秀!