这令人沮丧。这段代码根本不会运行,并且没有显示错误!
正如你在下面看到的那样,我在页面顶部有一个回显,但这并没有显示,但是如果我除了回声之外我删除所有其他代码,它会显示!
我虽然PHP是程序性的,但即使下面有错误,也应该显示回声。
发生什么事了!?
<?php
echo "test";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include 'models/Soccerseason.php';
class FootballData {
public $config;
public $baseUri;
public $title;
public $auth = false;
public function __construct() {
$this->config = parse_ini_file('config.ini', true);
if($this->config['authToken'] == '4e0aa9dc285343fbb1db8251d64a38c4' || !isset($this->config['authToken'])) {
$this->baseUri = $this->config['baseUri'];
$this->reqPrefs['http']['method'] = 'GET';
$this->reqPrefs['http']['header'] = 'X-Auth-Token: ' . $this->config['authToken'];
$this->auth = true;
}
}
public function getSoccerseasonById($id) {
echo "true";
if ($this->auth == true) {
$result;
$resource = 'soccerseasons/' . $id;
$response = file_get_contents($this->baseUri . $resource, false, stream_context_create());
if ($response == "" || $response == null) {
$response = file_get_contents($this->config['localBackup'] . $resource, false, stream_context_create());
$result = json_decode($response);
$response['title'] = 'Local Copy:';
$result = json_encode($response);
}
$result = json_decode($response);
return new Soccerseason($result);
} else {
return array('error' => 'API Key incorrect/not set, please amend in the config.');
}
}
}
$fixtures = new FootballData->getSoccerseasonById(426);
?>
答案 0 :(得分:1)
显示这些错误是用这一行修改你的php.ini:
value[0]
答案 1 :(得分:1)
如果存在解析错误,则不会运行echo
。还有 - 在最后一行。它应该是:$fixtures = (new FootballData)->getSoccerseasonById(426);
。
答案 2 :(得分:1)
您是否有足够的权限来更改 php.ini ?如果是,您可以修改display_errors以查看它们是否出现。尝试检查服务器日志,php会在错误日志中输出错误,即使它们在php.ini上被禁用。
答案 3 :(得分:1)