Can't printout class variable

From: Date: Tue, 24 Jan 2006 02:22:23 +0000
Subject: Can't printout class variable
Groups: php.general 
Request: Send a blank email to php-general+get-229146@lists.php.net to get a copy of this message
This should be simple. What am I doing wrong? Here is the code that is failing: $user = $_SESSION['user']; print_r($user); echo "Welcome " . $user->firstName; The print_r command prints out: __PHP_Incomplete_Class Object ( [__PHP_Incomplete_Class_Name] => User [isLoggedIn] => 1 [lastName] => Gunn [firstName] => Scott ) But the $user->firstName method doesn't return anything. Here is the class declaration: <?php class User { public $isLoggedIn = false; public $lastName = ""; public $firstName = ""; } ?> This fails after a redirect, but it's not a problem with losing the session variables since the print_r command does print out everything ok. However, the same code does work before the redirect (and print_r doesn't say "Incomplete_Class" it says the correct class name). I am redirecting to a relative path on the same server. Here is my redirect function: function redirect($url) { session_write_close(); header("Location: $url"); exit; } I'm pretty new to PHP so it's probably something simple. Go easy on me!

« previous php.general (#229146) next »