[php] how does function_exists work when there are namespaces?

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?

Mar.23,2021

var_dump(function_exists('Core\asd'));

when there is no namespace, the function is registered in the global function table. After there is a namespace, the function under the namespace is registered in the global function table with a namespace
function_exists ("funname"). If the function exists
has a namespace in the global function table, you can add a namespace before the function name

.
var_dump(function_exists('\Core\asd'));//bool(true)
var_dump(function_exists('\App\bbb'));//bool(true)

so predestined, I am also called Xiaobai
Why is it all true, for the first time? it is in the same space, of course, you can read functions or methods to each other

but why not the second time? first of all, if you give the class A namespace Core, then function asd () certainly belongs to this namespace, but you still use the previous method to read it. How can you read it? the correct way to judge is
var_dump (function_exists ('\ Core\ asd'));
)

.
Menu