【发布时间】:2015-11-29 20:04:19
【问题描述】:
我正在使用 DOM+php 从 html 网页中提取一些部分,并尝试将结果作为 $_SESSION 变量发送到其他页面,并最终更新 mysql 数据库。
HTML网页代码示例:
<html>
<body>
<div id="title">some title </div>
<div id="city">some city</div>
<div id="country">some country</div>
<div id="company">some company</div>
<div id="text">some text</div>
<body>
<html>
这是我用来获取数据并且正在运行的代码...我可以回显 $var:
<?php session_start(); ?>
---- some HTML---
<?
include('simple_html_dom.php');
$file = 'webpage.html';
$html = new simple_html_dom();
$html->load_file($file);
$title = $html->getElementById('title');
$city = $html->getElementById('city');
$country = $html->getElementById('country');
$company = $html->getElementById('company');
$text= $html->getElementById('text');
echo '<b>'.$title.'</b>';
$_SESSION['title'] = $title;
echo '<b>'.$city.'</b>';
$_SESSION['city'] = $city;
echo '<b>'.$country.'</b>';
..............
?>
我的问题是我无法使用 $_SESSION 将此 $var ($title,$city, ...) 发送到任何其他 php 页面...并且我收到此错误:
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string
【问题讨论】:
-
PHP 会话只能包含 serializable 数据。