没有方法光有属性有什么用呀? 叫我怎么取到里面的值? existence Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition cart of the object you are trying to operate on was loaded _before_ the session was started in D:\Lida\InfoChange.php on line 10 //上面第一行的是if(isset($Objcart)){echo...}来的。 //后面是用了$Objcart->GetOwner()来的。请问有什么方法能调用方法呢? //如果没有方法,如何取到属性值呢?
并不见得呀,几位高手。虽然我的问题没有解决,但这几个用来test的文件在我这儿却好用得很呐: //<?php //session test //1.php include("user.php"); session_start(); $user=new user("fuxiao","realname"); session_register("user"); $user->userid="keyizhijie"; echo '<br>session name is '.session_name(); session_name("yt"); echo $user->getid(); echo "<br>the new session name is "; echo session_name(); echo "<br>session id is ".session_id();echo "<a href='2.php'>2.php</a>"; ?>
<?php //2.php //session test,the test include those files :1.php,2,php,3,php; echo "<a href='3.php'>3.php</a>"; ?>
<?php //3.php //session test,the test include those files :1.php,2,php,3,php; include("user.php"); session_start(); if(isset($user)) {echo "user has already registed"; echo $user->getid(); echo session_id(); echo session_name(); } else { echo "tnnd,there is no session existence"; } ?>
to: alexxing(赤铸) 你听谁说的呀,谁说PHP目前的版本serialize 函数只支持对象的属性,不支持方法呀?你用的是PHP的哪个版本啊? 你好好看看电子工业出版社出的<<PHP4宝典>>第427页!!
不好意思,不知道一次至多贴三个,另外一个文件就是定义了那个类,有getid方法了. <<PHP 4.X与电子商务网站开发实战>>周浩编著 人民邮电出版 上面有个例子,直接注册对象为session变量.我上面的几个好象可以证明这点,(我的好像是PHP Version 4.2.3).不过,我原来的问题却还没有发现问题所在呀!!
$str = serialize($object);
取出后要去序列化:
$object = unserialize($str);另外,SESSION 只能保存对象的属性,方法会自动丢失
叫我怎么取到里面的值?
existence
Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition cart of the object you are trying to operate on was loaded _before_ the session was started in D:\Lida\InfoChange.php on line 10
//上面第一行的是if(isset($Objcart)){echo...}来的。
//后面是用了$Objcart->GetOwner()来的。请问有什么方法能调用方法呢?
//如果没有方法,如何取到属性值呢?
//<?php
//session test
//1.php
include("user.php");
session_start();
$user=new user("fuxiao","realname");
session_register("user");
$user->userid="keyizhijie";
echo '<br>session name is '.session_name();
session_name("yt");
echo $user->getid();
echo "<br>the new session name is ";
echo session_name();
echo "<br>session id is ".session_id();echo "<a href='2.php'>2.php</a>";
?>
//2.php
//session test,the test include those files :1.php,2,php,3,php;
echo "<a href='3.php'>3.php</a>";
?>
//3.php
//session test,the test include those files :1.php,2,php,3,php;
include("user.php");
session_start();
if(isset($user))
{echo "user has already registed";
echo $user->getid();
echo session_id();
echo session_name();
}
else
{
echo "tnnd,there is no session existence";
}
?>
你听谁说的呀,谁说PHP目前的版本serialize 函数只支持对象的属性,不支持方法呀?你用的是PHP的哪个版本啊?
你好好看看电子工业出版社出的<<PHP4宝典>>第427页!!
<<PHP 4.X与电子商务网站开发实战>>周浩编著 人民邮电出版
上面有个例子,直接注册对象为session变量.我上面的几个好象可以证明这点,(我的好像是PHP Version 4.2.3).不过,我原来的问题却还没有发现问题所在呀!!
我在session_start()之前包含了一个checklogin.php,这个文件中也有一个session_start(),我现在把它注释掉,就可以了!!
哎,这两天都吃不下饭呀!!
这个现象有谁能解释一下呢?为什么不能两次在同一处用session_start()另外,谁说session不支持对象(方法会没有)呀?
我现在也没有序列化,用得好好的。telescope(望远镜) alexxing(赤铸)谢谢你们了,日后再散分时,不会忘记两位的!
看来我的手册该更新了 :(
我的QQ是:9999790,欢迎几位加我!
加我的时候告诉我你用面向对象的PHP哦!