We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Why the class not found

Just look like below:


namespace App\Cl;

class SomeClass {}


namespace App\Cl;

$className = 'SomeClass';

$class = new $className(); // SomeClass Not found

$class = new SomeClass(); // here is correct

Why above two line is different...

edited Mar '14


$className = 'App\CI\SomeClass';

edited Mar '14

Thank you so much! Can you explain two class in same namespace, Why still need 'App\CI\' ? I want to know the reason...

Coz php interprets variable with class without context (so it doesn't know what is current namespace).