when learning namespaces, I encounter a pit, that is, when some of these methods are defined but cannot be found
without namespaces
<?php
class A {
function index () {
function asd (){}
var_dump(function_exists("asd"));
}
}
class Test extends A {
function doLogin () {
function bbb () {}
var_dump(function_exists("bbb"));
}
}
$test = new Test();
$test->index(); // bool(true)
$test->doLogin(); // bool(true)
when there is a namespace
<?php
namespace Core;
class A {
function index () {
function asd (){}
var_dump(function_exists("asd"));
}
}
namespace App;
use Core\A;
class Test extends A {
function doLogin () {
function bbb () {}
var_dump(function_exists("bbb"));
}
}
$test = new Test();
$test->index(); // bool(false)
$test->doLogin(); // bool(false)
Why? how do I get bool (true) when I have a namespace?