1

我想$wgScriptPath在我正在构建的 mediawiki 扩展中使用该变量。每当我访问该变量时,我都会收到错误“未定义的变量:wgScriptPath”。
有谁知道在 mediawiki 扩展中访问这些类型变量的正确方法?

提前致谢!

4

1 回答 1

0

您是否将其声明为全局?

function foo() {
    echo $wgScriptPath; // this will echo the local variable in the 
                        // function's scope, which of course does not exist
}

function foo() {
    global $wgScripPath;
    echo $wgScriptPath; // this will echo the global variable
}
于 2012-08-19T21:34:22.337 回答