Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的名称空间函数_Php_Function_Namespaces - Fatal编程技术网

php中的名称空间函数

php中的名称空间函数,php,function,namespaces,Php,Function,Namespaces,我在名称空间和函数方面遇到问题。我使用的是PHP7 我有一个文件: namespace profordable\app; function get_app() { if (!class_exists('profordable\app\app')) { return false; } global $global; if (!isset($$global)) { return false; } return $$gl

我在名称空间和函数方面遇到问题。我使用的是PHP7

我有一个文件:

namespace profordable\app;

function get_app() {
    if (!class_exists('profordable\app\app')) {
        return false;
    }
    global $global;
    if (!isset($$global)) {
        return false;
    }
    return $$global;
}

class app {
    ...
}
和我的主索引文件:

namespace profordable\app;
$global = 'app';
$app = new app;
和另一个文件作为文件(全局命名空间):

我似乎无法获取文件中的get_app函数,我已经测试过了,并且

var_dump(function_exists('profordable\app\get_app');
返回true,但当我尝试(在文件中)的组合时


它不起作用。请帮助

这在文件中起到了作用:

use function profordable\app\get_app as get_app;

它做什么或不做什么?错误是什么?没有错误,get_app()只返回null
use profordable\app;
use function profordable\app\get_app;
function some_function() {
    $app = get_app();
    $app = profordable\app\get_app();
    $app = \get_app();
    ...etc
}
use function profordable\app\get_app as get_app;