PHP页面间传递对象 页面之间只能传递字符串 ,要传递对象必须有层次关系的:比如iframe 或者 window.open 这样的页面才可以 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 若你new的要是服务器端的对象,那么只能遗憾的告诉你 :无法做到!! 页面间传递对象可以用session,cookie,url来实现.class test{ public $content = ''; function __construct($v) { $this->content = $v; } function say() { die( $this->content ); }}//session的实现方法session_start();if( isset($_SESSION['ob']) ){ $ob = unserialize($_SESSION['ob']); $ob->say();}else{ $_SESSION['ob'] = serialize( new test('hello,how are you?') );}//cookie的实现方法if( isset($_COOKIE['ob']) ){ $ob = unserialize( get_magic_quotes_gpc()? stripslashes($_COOKIE['ob']):$_COOKIE['ob'] ); $ob->say();}else{ setcookie( 'ob',serialize(new test('hello,how are you?')) );}//url的实现方法if( empty($_GET['ob']) ){ $address = $_SERVER['PHP_SELF'].'?ob='.urlencode(serialize(new test('hello,how are you?'))); header( "Location: $address" ); exit;}else{ $ob = unserialize( get_magic_quotes_gpc()? stripslashes($_GET['ob']):$_GET['ob'] ); $ob->say();} 刚试验了下,memcached可以传对象,前体是引用类的脚本能找到那个类,呵呵... sorry,我一直没试,相信一定对的。结贴。 求高手修复一个页面 php 如何实现无刷新删除图片? 迷茫 linux下phpMyadmin的安装 我用Php5.0和MySql5.0做网页出现的问题???(解决问题,立即给分) 如何用PHP来判断一个提交的POST表单是不是来自别的网站。 求解--去哪儿网笔试题目----这是中文分词吗 招聘WEB兼职开发人员 这句话有错误么?? 关于模糊查询的问题! 超级 急 --- 如何 恢复删除 后 的表 php 锁定文件的问题。
class test
{
public $content = '';
function __construct($v)
{
$this->content = $v;
}
function say()
{
die( $this->content );
}
}
//session的实现方法
session_start();
if( isset($_SESSION['ob']) )
{
$ob = unserialize($_SESSION['ob']);
$ob->say();
}
else
{
$_SESSION['ob'] = serialize( new test('hello,how are you?') );
}//cookie的实现方法
if( isset($_COOKIE['ob']) )
{
$ob = unserialize( get_magic_quotes_gpc()? stripslashes($_COOKIE['ob']):$_COOKIE['ob'] );
$ob->say();
}
else
{
setcookie( 'ob',serialize(new test('hello,how are you?')) );
}//url的实现方法
if( empty($_GET['ob']) )
{
$address = $_SERVER['PHP_SELF'].'?ob='.urlencode(serialize(new test('hello,how are you?')));
header( "Location: $address" );
exit;
}
else
{
$ob = unserialize( get_magic_quotes_gpc()? stripslashes($_GET['ob']):$_GET['ob'] );
$ob->say();
}