Hi All,

        I am having problems with a class and session_register().

        I define a class (parital implimentation below) with some variables
and call session_register at the top of each page.

        After I change pages, I end up with all three variables containing
the data from szAffiliateName.

        I have tried using the __sleep() function thus:

        function __sleep()
        {
                return array('szAffiliateName', 'szAffiliateImagePath',
'm_iAffiliateID');
        }

        and it just seems to break everything.

        I noticed that there is also a post in the anotated manual which
describes the problem (unfortunately there was not a following solution :)

        Any ideas would be appreciated.

Cheers,
Brad.



class CAffiliate
{

        // constructor

        function CAffiliate()
        {
                $szAffiliateName = "";
                $szAffiliateImagePath = "";
                $m_iAffiliateID = 0;
        }

        // "private" data memebers
        
        var $szAffiliateName;
        var $m_iAffiliateID;
        var $szAffiliateImagePath;

.
.
.
snip
.
.
.
        function GetAffiliateName()
        {
                return $this->$szAffiliateName;
        }
        
        function GetAffiliateImagePath()
        {
                return "images/" . $this->$szAffiliateImagePath . "/";
        }
        
        function GetAffiliateID()
        {
                return $this->$m_iAffiliateID;
        }
}
        

Regards,
Brad





>From the annotated reference:

I've been trying to do session_register with a test page and it keeps
taking the last value of the last variable assigned a value in the class
and making others that way.

so for example

if you do a:

$SomeClass->varone = "Something";
$SomeClass->vartwo = "Nothing";

if you do a:
 session_register("SomeClass");

on the next page when you do an echo $SomeClass->$varone; echo
$SomeClass->$vartwo; it will print out the value of
$SomeClass->$vartwo twice.  I dont know if this is just something I did
wrong, but this is what I'm getting.


-- 
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]

Reply via email to