PHP只是不会显示错误
这是令人沮丧的。这段代码根本无法运行,并且没有显示错误!PHP只是不会显示错误
正如你可以看到下面,我有在页面顶部的回声,这并不显示,但如果我删除所有除了回声其他代码,它显示!
我虽然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);
?>
显示这些错误是这一行来修改你的php.ini:
display_errors = on
我认为我添加的前3行会做到这一点,但?我似乎无法找到任何地方的cPanel来改变这些设置。 –
@MartynBall:PHP可能被设置为禁止通过'ini_set()'更改设置。并且'display_errors = off'你甚至不会看到'ini_set()'被禁用的警告。 –
cPanel附带错误日志部分,可让您查看由您的网站生成的错误 –
的echo
如果有语法错误,将不能运行。最后一行是 - 。它应该是:$fixtures = (new FootballData)->getSoccerseasonById(426);
。
羞耻它变得-1由于语法和我使用的措辞。语法警察周围。帖子很清楚,只是一些额外的挫败感。对帮助解决问题没有贡献,只是重新措词... -_- –