marcele Posted August 1, 2005 Share Posted August 1, 2005 In my previous post where I gave an example of a better way to pass around the $ipsclass object ..you said.. "I'll likely do that when PHP 5 is used more than PHP 4." .. The example I gave was based on php5 however you can do the same thing via php4..This way you have access to the $ipsclass object in any constructors. Just trying to help out ;) $ipsclass->sess = new session($ipsclass); class session{ var $ipsclass; var $ip_address; function session(&$ipsclass) { $this->ipsclass = &$ipsclass; $this->ip_address = $this->ipsclass->parse_clean_value($_SERVER['REMOTE_ADDR']); } Link to comment Share on other sites More sharing options...
Management Matt Posted August 1, 2005 Management Share Posted August 1, 2005 I'd rather pass by reference implicitly than by constructor. There are few if any occasions where passing ipsclass into the constructor is required. The ipsclass.php "initiate_ipsclass" is there not only for the ipsclass, but also because the settings aren't available until the DB is connected and queried, and some of the DB connection code is in ipsclass.php. The only real time not being able to pass through to the constructor has caused a work around is class_email.php. As calltime references are being depreciated in PHP 5, I figured I'd not rely on them as a method of passing ipsclass around. Link to comment Share on other sites More sharing options...
marcele Posted August 1, 2005 Share Posted August 1, 2005 Ascalltimereferencesare being depreciated in PHP 5, I figured I'd not rely on them as amethod of passing ipsclass around. This isn't a calltime reference.. The reference is handled implicitly by the constructor declaration which is the desired method in php5. Here is an example: BAD DON'T USE $ipsclass->sess = new session(&$ipsclass); GOOD USE $ipsclass->sess = new session($ipsclass); The class constructor should decide if the object should be a reference or not ... Not the logic of the page controller :P class session{ var $ipsclass; var $ip_address; function session(&$ipsclass) { $this->ipsclass = &$ipsclass; $this->ip_address = $this->ipsclass->parse_clean_value($_SERVER['REMOTE_ADDR']); } Link to comment Share on other sites More sharing options...
Management Matt Posted August 2, 2005 Management Share Posted August 2, 2005 This is not a bug in IPB but is more of a feature suggestion. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.