We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

dynamic function can't be recgonized

I simply copied the code from INVO tutorial

$di->set('db', function() use ($config) { $dbclass = 'Phalcon\Db\Adapter\Pdo\' . $config->database->adapter; return new $dbclass(array( "host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->name )); });

but it returns

Undefined variable: dbclass

I know it's dynamic function name, and the syntax seems all right, I can't understand it, can anyone help me?

the envirement is win7x64, WAMP-2.5x64, Phalcon-2.0.2 x64



13.0k
Accepted
answer
 $dbclass = 'Phalcon\Db\Adapter\Pdo\'

change to

 $dbclass = 'Phalcon\Db\Adapter\Pdo\\'

https://github.com/phalcon/invo/blob/master/app/config/services.php#L85