note 86894 deleted from language.oop by danbrown
| From: | danbrown@php.net | Date: | Sun, 09 Nov 2008 23:36:57 +0000 |
| Subject: | note 86894 deleted from language.oop by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146327@lists.php.net to get a copy of this message | ||
Note Submitter: mozo_grand at yahoo dot com
----
Stated above by 'buzz77 at gmx dot net' assigning classes to session variables appears to
be incorrect.
Using php v5.05 it does not work, i suspect the user had register_globals set to on giving incorrect
results.
My test code was as follows
Created a library file for the class
<?php
// class-test-lib.php
class simple {
function dummy() {
print "TEST SUCCESSFUL !";
}
}
?>
created a test php file
<?php
require("class-test-lib.php");
session_start();
?>
<html>
<head>
<title>Class Test Page 1</title>
</head>
<body>
<?php
session_register("testVar");
$testVar=new simple();
$testVar->dummy();
?>
<br />
<a href="class-test2.php">Second Page</a>
</body>
</html>
Outputs correctly the message from the class
created the second page test php file
<?php
require("class-test-lib.php");
session_start();
?>
html>
<head>
<title>Class Test Page 2</title>
</head>
<body>
<?php
$testVar->dummy();
?>
</body>
</html>
results in the following error:
Notice: Undefined variable: testVar in c:\Inetpub\wwwroot\class-test2.php on line 14
Fatal error: Call to a member function dummy() on a non-object in c:\Inetpub\wwwroot\class-test2.php
on line 14
It appears that the session registration is not effective and the original posters results are more
likely due to having globals on.
I have not found a solution to this problem.