开发者

Is UNSET() compatible with autoload

开发者 https://www.devze.com 2023-04-07 04:17 出处:网络
Using Amazon MWS code config.ini.php to set up classes for MarketplaceWebServices. This used autoload defintions to create variables using new.

Using Amazon MWS code config.ini.php to set up classes for MarketplaceWebServices.

This used autoload defintions to create variables using new.

As we are using different authorization credentials for different Amazon sites I have needed to change the details beteen sites.

The use of UNSET()

unset($service);

before

$service = new MarketplaceWebService_Client(
     $AWS_ACCESS_KEY_ID, 
     $AWS_SECRET_ACCESS_KEY, 
     $config,
     APPLICATION_NAME,
     APPLICATION_VERSION
);

开发者_开发知识库results in $service not being an object on being called the second time.

Which brings me to the question "Is UNSET() compatible with autoload ?"


unset() has nothing to do with autoloading, and will not interfer with it. Once the class is loaded using an autoloader, unset()ing an instance will not cause it to not be available any longer.

If that were the case, you'd get an error about MarketplaceWebService_Client not being an avaliable class.


Is UNSET() compatible with autoload ?

Yes. (Simple question, simple answer.)


Running the following demonstrates that unset should work OK with autoload. The test class didn't use __contruct(). So it looks like something in MarketplaceWebService_Client MWS is upsetting the apple cart.

$shipping_calc = new shipping_calc();
echo "ORIG \$shipping_calc=" . print_r($shipping_calc, true);

unset($shipping_calc);
echo "UNSET() \$shipping_calc=" . print_r($shipping_calc, true);

$shipping_calc = new shipping_calc();
echo "NEW \$shipping_calc=" . print_r($shipping_calc, true);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号