Re: classes and return values
| From: | Jochem Maas | Date: | Mon, 27 Feb 2006 20:33:37 +0000 |
| Subject: | Re: classes and return values | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231155@lists.php.net to get a copy of this message | ||
Jason Gerfen wrote:
I am attempting to work up a class and because I am unfamiliar with some of the code flow I am only able to get a return value of 'object'. How can I pull the data out of a class?which data? It doesn't seem as if anyone knows what your trying to do. (try to explain it again) there is a difference between class and object - it's quite fundamental to the whole OO concept. <? // the following is a [php4] class class Test { var $foo = "bar"; function getData() { return $this->foo; } } // $t is an object (assuming an error doesn't occur when instantiating it) $t = new Test; // this is an echo statement that outputs the return val from a method call echo $t->getData(),"\n";
Any help, or pointers on what I am doing wrong is appreciated. class myAuth { var $user; var $pass; var $lvl; var $id; function login( $user, $pass ) { require 'templates/auth.tmplte.php'; global $defined, $error_message; if( ( empty( $user ) ) || ( empty( $pass ) ) ) { if( $_SESSION['count']++ >= 1 ) { $errors = "<img src=\"images/error.jpg\"> <b>You need to provide a user name and password!</b><br><br>";}$data = new myAuthTmplte(); $data->auth_template( 1, NULL, NULL, NULL, $errors ); logs( $error_message['str_chk'] ); } } }