I'm new to php and trying to use namespace
s for the first time and I have this crazy problem in a big php file (simplified below):
B.php:
namespace Logic;
class C {}
class B {}
A.php:
use Logic\C;
class A extends \BaseClass {
public function __construct() {}
// [...500 lines of code...]
private function hi() { $c = new C(); }
}
The hi
method gives the error: Class 'Logic\\C' not found in A.php
But if I just reference B in the constructor of A, it works as expected:
class A extends \Base {
public function __construct() { $dummy = new C(); }
// [...500 lines of code...]
private function hi() { $c = new C(); }
}
When the hi
method in the modified code above is run, there are no problems.
Can anybody think of a reasonable explanation for why this happens? Am I misusing namespaces in php?