Class calling Class returning 'object'
| From: | Jason Gerfen | Date: | Mon, 27 Feb 2006 16:06:49 +0000 |
| Subject: | Class calling Class returning 'object' | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231140@lists.php.net to get a copy of this message | ||
I am in need of some assistance working with classes. I have a function (X) which calls a class (A), that class calls another class (B) and returns the results. At this point I think I am doing everything correctly within' class A because if I echo the results of Class A calling Class B the data is displayed. However, when I use 'return $data' from function X (ex. $data = $ClassA->function( $var1, $var2 ); ) the word 'object' is being displayed in the browser.
Here is the code; any help, tips, pointers is appreciated.
// function 'chooser' calls class 'myAuth' and returns $data
function chooser( $level, $page, $user, $pass ) {
if( $page == "auth" ) {
require 'auth.inc.php';
$data = new myAuth;
$data = $data->login( $_POST['user'], $_POST['pass'] );
} else {
$data = "error";
}
return $data;
}
// myAuth class
class myAuth
{
var $data;
function login( $user, $pass ) {
if( ( empty( $user ) ) || ( empty( $pass ) ) ) {
$data = new myAuthTmplte();
$data = $data->AuthTemplate( 1, NULL, NULL, NULL, $errors );
} else {
$data = "error";
}
return $data; // If I do echo $data I can see the results of calling the myAuthTmplte Class
}
// myAuthTmplte class
class myAuthTmplte
{
var $data;
function AuthTemplate( $cmd, $args, $num, $message, $errors ) {
$data = "I should be seeing this text right here"; // This data should be displayed but I am only seeing the word 'object' in the browser
return $data;
}
--
Jason Gerfen
"When asked what love is:
Love is the Jager talking."
~Craig Baldo