Jump to content


Class Logic Issue

  • Please log in to reply
1 reply to this topic

#1 johndapunk

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 17 September 2006 - 12:27 AM

I am having a little problem understanding the logic behind this. I study some code (occasionally), and I saw this in IPB's scripts. At the begining of a class, it will have:
PHP Code:
class classname {
var $ipsclass;

and then later on, it is able to use the $ipsclass object like so:
PHP Code:

I just don't understand how it uses the $ipsclass object without declaring something like:
$this->ipsclass = new ipsclass;

Here, I'll post my code so you might get a better point of it.

PHP Code:
* Test Super Class
global $SUPER;
$SUPER = new super;
REQUIRE_ONCE( 'test_three.php' );
class super {
public $num;
function __construct( ) {
    $this->num = 5;

PHP Code:
* Test Three

class three {
public function f( $x ) {
    $f = 5 * intval( $x );
    echo $f;
$three = new three;
$three->f( $super->num );

And it echos "0", which obviously means that $super->num in test_three.php is undefined.

I have tried to figure out how it does it, but I still don't understand. If you get what I'm asking, please respond. If you think you might know the answer, but don't really understand the question, please IM me at jondapunk (AIM), or johndapunk@hotmail.com (MSN).

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 17 September 2006 - 01:25 PM

in class three, change $super to $SUPER (case sensitive)
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users