gpt4 book ai didi

php - fatal error : Class 'Services_JSON' not found

转载 作者:行者123 更新时间:2023-11-29 01:11:24 25 4
gpt4 key购买 nike

我尝试在 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/

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