简体   繁体   English

全局变量PHP

[英]Global Variables PHP

I have some problems with PHP global variables. 我在使用PHP全局变量时遇到一些问题。

can i define global variables in the function and use that in another function? 我可以在函数中定义全局变量并在另一个函数中使用它吗?

can i Define global variables in another global variables and use second global variable? 我可以在另一个全局变量中定义全局变量并使用第二个全局变量吗?

can i define global variables in a function, and use this function in another functions? 我可以在一个函数中定义全局变量,并在另一个函数中使用此函数吗?

how about this question? 这个问题怎么样?

global $y; // $y = 5

$x = 10 * $y; // $x = 50

function numbers() {

    global $x;

    echo $x; // $x = 0;

}

Please find a nice article on Global variables in php - It will tell you about various global variables that exist in Php Language and how to use and access these variables and their purpose. 请在php中找到有关全局变量的不错的文章-它会告诉您Php语言中存在的各种全局变量,以及如何使用和访问这些变量及其目的。

Reference : https://www.w3elearners.com/php/global-variables/ 参考: https : //www.w3elearners.com/php/global-variables/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM