[PHP] passing object variable from page to page. Please disregard the previous!

2001-10-03 Thread Ming-Chieh Lee

Hello,

> I have a question on how to pass object variable from page to page. Here
is

> something that I found, but it doesn't work. I would greatly appreciate if

> someone can help:

> 1. does it matter if I include first, then so session_start()?

>

>

> file1.php

>  include ('class.myclass.php');

> session_start();

> $myvar = new MyClass;

>

> $myvar->who = "me";

> // this is where my doubt reside !!!

> session_register ('myvar'); // like this ?

>

> // don't need to register stuff in the class, it's already there.

> // session_register ('who'); ?>

> _

> file2.php

>session_start();

> include ('class.myclass.php');

> // using an "&" you won't make a copy and you

> // can work directly on the session var

> $myvar = &$HTTP_SESSION_VARS['myvar'];

>

> // should print "object"

> echo "" . gettype($myvar);

>

> // use the object, "who" is not a session var

> echo "Session Var : " .$myvar->who. "";

>

> //echo "Session Var : " .$HTTP_SESSION_VARS['myvar']['who'] . "";

> //echo "Session Var : " .$HTTP_SESSION_VARS['myvar->who'] . "";

> ?>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




php-general@lists.php.net

2001-09-26 Thread Ming-Chieh Lee

just for clarity, why do we need to reference a variable when the variable
already contain a reference?  Thanks

"Ming-Chieh Lee" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> does anyone know what does &$this mean?  I saw this on the php.net
> > tuturial
> > > for references inside a constructor.
> > > I thought that $this is already a reference?
> > > The way it was used :
> > > class Foo
> > > {
> > > function Foo($name)
> > > {
> > > // create a reference inside the global array $globalref
> > > global $globalref;
> > > $globalref[] = &$this;
> > > // set name to passed value
> > > $this->setName($name);
> > > // and put it out
> > > $this->echoName();
> > > }
> > > thanks for any input!
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




php-general@lists.php.net

2001-09-26 Thread Ming-Chieh Lee

does anyone know what does &$this mean?  I saw this on the php.net
> tuturial
> > for references inside a constructor.
> > I thought that $this is already a reference?
> > The way it was used :
> > class Foo
> > {
> > function Foo($name)
> > {
> > // create a reference inside the global array $globalref
> > global $globalref;
> > $globalref[] = &$this;
> > // set name to passed value
> > $this->setName($name);
> > // and put it out
> > $this->echoName();
> > }
> > thanks for any input!




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]