在页面间传递,最好就是使用SESSION,注册变量到SESSION中

解决方案 »

  1.   

    --------------------以下是test.php
    <?
    class A
    {
      var $tmp1;
      var $tmp2;
    }session_start();
    $test=new A;
    $test->tmp1="a";
    $test->tmp2="b";
    $HTTP_SESSION_VARS["test"]=$test;
    ?>------------------------------以下是test2.php
    <?php
    class A
    {
      var $tmp1;
      var $tmp2;
    }session_start();
    echo $HTTP_SESSION_VARS["test"]->tmp1,$HTTP_SESSION_VARS["test"]->tmp2;
    ?>----------------------------------
    请先运行test.php 再运行test2.php
    如果你的PHP设置正确的话 应该最后能看到ab在程序间用SESSION传递对象 要注意 在每个需要传递的程序中,都要有类的声明.顺便以此程序表示我的最新认识:原来直接修改$HTTP_SESSION_VARS也得的.呵呵...