Rupesh Patel
Rupesh Patel

Reputation: 3065

How to use default php classes in my namespace?

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?

Upvotes: 12

Views: 11440

Answers (1)

Leri
Leri

Reputation: 12535

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

Upvotes: 15

Related Questions