当我尝试通过浏览器访问.php文件时,在我的本地wamp服务器上运行它会给我ERR_CONNECTION_RESET
。怎么回事?
<?php
$catalog = simplexml_load_file('http://www.w3schools.com/xml/cd_catalog.xml');
session_start();
if (!isset($_SESSION['selection'])) {
$_SESSION['selection'] = array();
}
array_push($_SESSION['selection'], $catalog->CD[0]);
?>
这是var_dump($catalog)
object(SimpleXMLElement)[1]
public 'CD' =>
array (size=26)
0 =>
object(SimpleXMLElement)[2]
public 'TITLE' => string 'Empire Burlesque' (length=16)
public 'ARTIST' => string 'Bob Dylan' (length=9)
public 'COUNTRY' => string 'USA' (length=3)
public 'COMPANY' => string 'Columbia' (length=8)
public 'PRICE' => string '10.90' (length=5)
public 'YEAR' => string '1985' (length=4)
1 => [...]
编辑: 通过查看建议的apache日志找到了这个:
[Tue Apr 02 09:34:54 2013] [error] [client 127.0.0.1] PHP Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in [no active file]:0\nStack trace:\n#0 {main}\n thrown in [no active file] on line 0
所以我猜问题是php的会话序列化不允许使用SimpleXMLElements。我会保存索引或其他内容。
答案 0 :(得分:3)
在您的程序中插入一些内容,如下所示:
error_reporting(E_ALL);
ini_set('error_log', 'phperror.log');
ini_set('log_errors_max_len', 0);
ini_set('log_errors', true);
并在出错后查看错误文件。