Guest Posted May 22, 2003 Posted May 22, 2003 I have a case where I need to create two instances of the same class, i.e the payment class. The thing is that when I create the second instance I get this error "Fatal error: Cannot redeclare class payment in checkout_paypalipn.php on line 15". This is due to how the payment class is written, it's the include statement in the constructor that is causing this. Why use "include" instead of "include_once"? Is there a reason to this? Is it safe to change the code to: // class constructor function payment($module = '') { global $payment, $language, $PHP_SELF; ... for ($i=0, $n=sizeof($include_modules); $i<$n; $i++) { //changed from "include" to "include_once" //include(DIR_WS_LANGUAGES . $language . '/modules/payment/' . $include_modules[$i]['file']); //include(DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file']); include_once(DIR_WS_LANGUAGES . $language . '/modules/payment/' . $include_modules[$i]['file']); include_once(DIR_WS_MODULES . 'payment/' . $include_modules[$i]['file']); $GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class']; } If it's safe I think this should be implemented all over the shop. /Fred
mattice Posted May 22, 2003 Posted May 22, 2003 I think it is due to php3 compatibility.. that doesn't support include_once I think. "Politics is the art of preventing people from taking part in affairs which properly concern them"
Recommended Posts
Archived
This topic is now archived and is closed to further replies.