Re: Class calling Class returning 'object'

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

 



Jason Gerfen wrote:
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'] );

<snip>

Please rename your variables!

You're creating an object called 'data' then assigning it to text - which gets even more confusing when you use the same idea in your other classes.


$authclass = new myAuth;
$login_check = $authclass->login(....)


Way easier to read and follow - you'll find your bug easily enough by doing this.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
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