In class_core.php, global $ _ G indicates that, for the first time, a global variable is passed for the second time, instead of a global variable.

Source: Internet
Author: User
In class_core.php, global $ _ G indicates the first time that a global variable is passed for the second time, instead of a global source: www. discuz. netforum. php? Modviewthread & amp; tid3007341 rating: global $ _ G meaning & nbsp; the first time to declare that this is a global variable, the second time to indicate that the variable is passed, without the definition of global $ _ G in class_core.php for the first time to declare that this is the second time that the global variable is passed, rather than the global variable
Source: http://www.discuz.net/forum.php? Mod = viewthread & tid = 3007341.
Rating: global $ _ G indicates the first time that a global variable is passed for the second time.
As you may find, the DZ plug-in has never been used. the meaning of this variable is explained as follows:
/Source/class/discuz/discuz_application.php (X2.5)
/Source/class/class_core.php (X2.0)
In the _ init_env () method of this file, global $ _ G is used to declare that this is a global variable, which stores the global information most frequently used by the system, this is mainly for the convenience of subsequent functions. For example, if I want to know the UID of the current user, I can simply read $ _ G ['uid'] without having to query the session or database twice, which improves the efficiency, write other program modules, and the amount of code will become very concise.

If you want to ask where the definition is, this is the section (omitted from a large section ):

Global $ _ G; // to declare that this is a global variable
$ _ G = array (
'Uid' => 0,
'Username' => '',
..................
);



In other files except this file, if global $ _ G is used, it indicates to pass this variable.
For example, in plug-in development, there is a method like this:

Function viewthread_postfooter_output (){
Global $ _ G; // indicates passing variables instead of declaring global variables.
Return $ _ G ['uid'];
}



For developers, the $ _ G variable has the meaning of "read-only". In other words, when no one writes a program, it can be initialized at will.

In addition, as a commercial institution rather than a public welfare scientific research institution, the staff are not obligated to tell you the meaning of the code. for the so-called readability, please learn more and understand it by yourself? This is like no hotel actively tells customers about the recipe of the dish.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.