当register_globals关闭时,如何访问全局变量? [英] how does one access global variables when register_globals is off?
本文介绍了当register_globals关闭时,如何访问全局变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在我的代码顶部设置一个变量,如下所示:
$ name =" Lawrence";
它现在是一个全局变量。
如果,稍后,在函数中,我想这样做:
function uppercaseName(){
global $ name;
$ name = ucfirst($ name);
}
全局关键字是否有效?如果没有,我在哪里可以找到$ name
变量?
解决方案
name =" Lawrence" ;;
它现在是一个全局变量。
如果,稍后,在函数中,我想这样做:
函数uppercaseName(){
global
name;
< blockquote> name = ucfirst(
If I set a variable at the top of my code like this:
$name = "Lawrence";
It is now a global variable.
If, later on, in a function, I want to do this:
function uppercaseName() {
global $name;
$name = ucfirst($name);
}
Will the global keyword work? If not, where do I find the $name
variable?
解决方案
name = "Lawrence";
It is now a global variable.
If, later on, in a function, I want to do this:
function uppercaseName() {
global
name;
name = ucfirst(
这篇关于当register_globals关闭时,如何访问全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文