gpt4 book ai didi

当 Echo 不存在时 PHP 服务器错误 500?

转载 作者:搜寻专家 更新时间:2023-10-31 21:04:50 24 4
gpt4 key购买 nike

当我在某个位置添加回显时,我的 php 代码工作正常,但是当我删除简单的 echo "hello"; 行时,它不会加载 php 页面,它只显示服务器错误500.

以下代码有效:

require 'steam.php';
$steam = new steam();
$api = "FC1D74A835829EB99A571235A499638A";
$query = 'ari9';

$communityID = $steam->getID($query, $api);
$userInfo = $steam->getUserInfo($communityID, $api);

echo "hello";

$info = array(
'communityID' => $communityID,
'steamID' => $steam->$convertToSteamID($communityID),
'personaname' => $userInfo['personaname'],
'profileurl' => $userInfo['profileurl'],
'lastlogoff' => $userInfo['lastlogoff'],
);

foreach ($info as $key => $value) {
if (strlen($value)===0) {
$info[$key] = false;
}
echo $key." -> ".$value."<br>";
}
echo json_encode($info);

下面的代码有效:

require 'steam.php';
$steam = new steam();
$api = "FC1D74A835829EB99A571235A499638A";
$query = 'ari9';

$communityID = $steam->getID($query, $api);
$userInfo = $steam->getUserInfo($communityID, $api);

$info = array(
'communityID' => $communityID,
'steamID' => $steam->$convertToSteamID($communityID),
'personaname' => $userInfo['personaname'],
'profileurl' => $userInfo['profileurl'],
'lastlogoff' => $userInfo['lastlogoff'],
);

foreach ($info as $key => $value) {
if (strlen($value)===0) {
$info[$key] = false;
}
echo $key." -> ".$value."<br>";
}
echo json_encode($info);

并且以下代码有效:

require 'steam.php';
$steam = new steam();
$api = "FC1D74A835829EB99A571235A499638A";
$query = 'ari9';

$communityID = $steam->getID($query, $api);
$userInfo = $steam->getUserInfo($communityID, $api);

$info = array(
'communityID' => $communityID,
'steamID' => $steam->$convertToSteamID($communityID),
'personaname' => $userInfo['personaname'],
'profileurl' => $userInfo['profileurl'],
'lastlogoff' => $userInfo['lastlogoff'],
);

foreach ($info as $key => $value) {
if (strlen($value)===0) {
$info[$key] = false;
}
echo $key." -> ".$value."<br>";
}
echo json_encode($info);

echo "Hello";

第一段代码在第 9 行有回显,第二段代码与第一段相同,除了第 9 行的回显被删除。我对此感到困惑。

最佳答案

问题是这个 $steam->$convertToSteamID 正在寻找一个函数,该函数的名称与变量值是什么有关。当没有 echo 时你得到 500 的原因是因为当你发送服务于 200 的 echo 时。你的日志中应该有事件显示错误。一个页面上不能有 2 个状态代码。

所以只需将您的函数调用更改为:

$steam->convertToSteamID

你应该没问题。

关于当 Echo 不存在时 PHP 服务器错误 500?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34373349/

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