I've got the following two files:
pre_form.php
<?php
class my_class {
var $prop1 = "abc";
var $prop2 = "def";
function my_class() {
}
function getprop1() {
return $this->prop1;
}
}
session_start();
$norman = New my_class;
session_register( "norman" );
header( "Location: forms.php " );
?>
form.php
<?php
session_start();
if( is_object($norman) ) {
echo $norman->prop1;
} else {
echo "No";
}
?>
When I run pre_form.php it goes through its thing with no problem and jumps to form.php and then spits out the following:
"Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition my_class of the object you are trying to operate on was loaded before the session was started in /home/chariot/public_html/test/sessions/forms.php on line 4"
If I change "echo $norman->prop1;" to "print_r(get_object_vars($norman));" I get:
Array
(
[__PHP_Incomplete_Class_Name] => my_class
[prop1] => abc
[prop2] => def
)
If I replace the "header(..." in form.php with "print_r(get_object_vars($norman));" I get the following:
Array
(
[prop1] => abc
[prop2] => def
)
Anyone know why my_class breaks after being passed through a session variable?