<?
//t01.php
class test
{
var $p1;
var $p2;
}
?>
//////////////////////////////////////////
<?
session_start();
session_register("ses_Test");
//t02.php
require("t01.php");
$aTest = new test;
$aTest->p1 = "p1";
$aTest->p2 = "p2";
echo $aTest->p1;
echo $aTest->p2;
$ses_Test = $aTest;
?>
<A HREF="t03.php">t03.php</A>
//////////////////////////////////////////
<?
session_start();
//t03.php
echo $ses_Test->p1;
echo $ses_Test->p2;
?>
//////////////////////////////////////////
这是在ie中浏览到t03.php时的效果:Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition test of the object you are trying to operate on was loaded _before_ the session was started in d:\apache group\apache\htdocs\\t03.php on line 3

解决方案 »

  1.   

    多谢宇凡! 
    我说的就是你这种思路 
    我自己的测试也是一样的结果!
    那也就是说这样行不通了??你没有没试过可以做到相似效果的方法!
    使多个页面共用一个连接对象,来访问mysql! 
    提高速度~??????加到100分!欢迎大家参于讨论,给小弟讲了经验
      

  2.   

    哦?我记得数据库的连接好象是可以的哟?看看:<?
    session_start();
    session_register("ses_conn");
    //t01.php
    $conn = mysql_connect("localhost","","");
    echo $conn;
    $ses_conn = $conn;
    ?>
    <A HREF="t02.php">t02.php</A>
    ////////////////////////////////////////////////////////
    <?
    session_start();
    //t02.php
    echo $ses_conn;
    echo "<br>";
    echo mysql_select_db("glasscity");
    echo "<br>";
    $sql = "select * from User";
    $res = mysql_query($sql);
    echo $res;
    echo "<br>";
    echo mysql_num_rows($res);
    echo "<br>";
    ?>
    ///////////////////////////////////////////////
    以下是IE中的结果:
    0
    1
    Resource id #2
    2
      

  3.   

    把连接的返回值存入session就可以,在下个页面调用