Php 实例化错误-名称已在使用中
我正在使用一个库并实例化如下对象:Php 实例化错误-名称已在使用中,php,class,object,Php,Class,Object,我正在使用一个库并实例化如下对象: use \DTS\eBaySDK\Constants; use \DTS\eBaySDK\Finding\Services; use \DTS\eBaySDK\Finding\Types; use \DTS\eBaySDK\Shopping\Services; use \DTS\eBaySDK\Shopping\Types; use \DTS\eBaySDK\Shopping\Enums; use \DTS\eBaySDK\Finding\Services
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Finding\Services;
use \DTS\eBaySDK\Finding\Types;
use \DTS\eBaySDK\Shopping\Services;
use \DTS\eBaySDK\Shopping\Types;
use \DTS\eBaySDK\Shopping\Enums;
use \DTS\eBaySDK\Finding\Services as ServicesOne;
use \DTS\eBaySDK\Shopping\Services as ServicesTwo;
这会导致错误:
致命错误:无法将DTS\eBaySDK\Shopping\Services用作服务,因为该名称已在…中使用。
但是,如果我在单独的php文件中使用它们,它们就可以正常工作。我应该在这里更改什么?您可以给他们这样一个别名:
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Finding\Services;
use \DTS\eBaySDK\Finding\Types;
use \DTS\eBaySDK\Shopping\Services;
use \DTS\eBaySDK\Shopping\Types;
use \DTS\eBaySDK\Shopping\Enums;
use \DTS\eBaySDK\Finding\Services as ServicesOne;
use \DTS\eBaySDK\Shopping\Services as ServicesTwo;
您可以给他们这样一个别名:
use \DTS\eBaySDK\Constants;
use \DTS\eBaySDK\Finding\Services;
use \DTS\eBaySDK\Finding\Types;
use \DTS\eBaySDK\Shopping\Services;
use \DTS\eBaySDK\Shopping\Types;
use \DTS\eBaySDK\Shopping\Enums;
use \DTS\eBaySDK\Finding\Services as ServicesOne;
use \DTS\eBaySDK\Shopping\Services as ServicesTwo;
oned是因为它是正确的,尽管你应该尝试给它们更多有意义的名称以便于维护和可读。oned是因为它是正确的,尽管你应该尝试给它们更多有意义的名称以便于维护和可读。