Welcome Guest, Not a member yet? Register   Sign In
'Class X not found' error
#4

You're forgetting about a how namespaces work. Since that file defined in namespace App\Libraries, all other classes will be assumed to be in that namespace unless other wise specified. Since you don't have anything to tell it otherwise, it's looking for PDO within the current namespace, App\Libraries. There are two solutions:

1. Prepend a backslash to PDO so it knows to look in the "root" namespace.

Code:
$db = new \PDO(...);

2. Tell it you're going to use that class at the top of file:

Code:
use PDO;
Reply


Messages In This Thread
'Class X not found' error - by donpwinston - 04-22-2017, 09:26 PM
RE: 'Class X not found' error - by skunkbad - 04-22-2017, 09:32 PM
RE: 'Class X not found' error - by donpwinston - 04-22-2017, 09:52 PM
RE: 'Class X not found' error - by sv3tli0 - 04-24-2017, 03:56 AM
RE: 'Class X not found' error - by kilishan - 04-23-2017, 07:03 PM



Theme © iAndrew 2016 - Forum software by © MyBB