How to use default php classes in my namespace?

2020-08-13 07:59发布

问题:

I am using namespaces to resolve class name conflicts in two of the SDKs I am using in my project

I have declared a name space in one of the file like

namespace temp;

class abc extends stdClass
{
  // my class def
} 

when i am hitting this code i get error says temp/stdClass not found, so I need to use all default php structures, interfaces like iterators etc. so how can I import the default namespace of php or do any another setting I am missing?

回答1:

Add \ before any global class, function and constant (stdClass in your example). Here is more information how to use namespaces.