Class calling Class returning 'object'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux