johndapunk Posted September 17, 2006 Share Posted September 17, 2006 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:[code]<?phpclass classname {var $ipsclass;...}?>[/code]and then later on, it is able to use the $ipsclass object like so:PHP Code:[code]$this->ipsclass->...[/code] I just don't understand how it uses the $ipsclass object without declaring something like:[code]$this->ipsclass = new ipsclass;[/code]Here, I'll post my code so you might get a better point of it.super.php:PHP Code:[code]<?php/*** Test Super Class**/global $SUPER;$SUPER = new super;REQUIRE_ONCE( 'test_three.php' );class super {public $num;function __construct( ) { $this->num = 5; }}?>[/code]test_three.php:PHP Code:[code]<?php /*** Test Three**/class three {public function f( $x ) { $f = 5 * intval( $x ); echo $f;}}$three = new three;$three->f( $super->num );?>[/code]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). Quote Link to comment Share on other sites More sharing options...
Barand Posted September 17, 2006 Share Posted September 17, 2006 in class three, change $super to $SUPER (case sensitive) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.