|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-06-20 19:06 UTC] stas at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Mon Jun 15 22:00:02 2026 UTC |
I've put three short pages that cause this problem for php 4.0.0. Seems that when an instance of a class is put into a session it becomes unable to access member functions of that instance (not the class, just that instance, as these scripts show), but it can still see variables. -------------classdec.php---------- <? // class declaration class TestClass { var $a; function heh($str) { echo $str . "<br>"; } } ?> ----------index.php---------- <? session_register("sessionvar"); Include("classdec.php"); // creating an instance of a class to pass as a session var to page.php $sessionvar = new TestClass; $sessionvar->a = "someval"; echo "<a href=page.php>link</a>"; ?> ----------page.php----------- <? session_register("sessionvar"); Include("classdec.php"); $anothervar = new TestClass; // I can use the variables of this instance that was created on index.php and put in a session echo $sessionvar->a . "<br>"; // I can call this function on another instance of the same class that I created on this page $anothervar->heh("this is output from the same function that generates an error on the next line"); // .....crash telling me it's an undefined function. $sessionvar->heh("rhewswh"); ?> ======================================================= produces following output on page.php after following the link from index.php: someval this is output from the same function that generates an error on the next line Fatal error: Call to undefined function: heh() in <path>/page.php on line 12 ============== any comments would be appreciated.