0

I want to extend standard PDO class. So i have:

namespace Example;

class NewPDO extends PDO {}

but i get the following error :

Fatal error: Class 'Example\PDO' not found in /home/hdocs/lab/index.php on line 4

I know that's because PDO class is not within Example namespace.
how can i solve that ?

1 Answer 1

5

PDO is in global namespace, you should add \ before it.

namespace Example;

class NewPDO extends \PDO {}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.