What is the use of php to declare global variables outside the function?

Source: Internet
Author: User
What is the use of php to declare global variables outside the function? Php wordpress global

What is the use of php to declare global variables outside the function?

I see the following section in the wordpress wp-settings.php file:

/* * These can't be directly globalized in version.php. When updating, * we're including version.php from another install and don't want * these values to be overridden if already set. */global $wp_version, $wp_db_version, $tinymce_version, $required_php_version, $required_mysql_version;require( ABSPATH . WPINC . '/version.php' );


Sorry, please explain. thank you! ^_^


Reply to discussion (solution)

No effect
And not seen in wp-settings.php
Global $ wp_version, $ wp_db_version, $ tinymce_version, $ required_php_version, $ required_mysql_version;
Only
Require (ABSPATH. WPINC. '/version. php ');

No effect

Global
$ A = 1;
$ B = 2;

Function Sum ()
{
Global $ a, $ B;

$ B = $ a + $ B;
}

Sum ();
Echo $ B;
?>
The output of the above script is "3 ". After the global variables $ a and $ B are declared in the function, all references to any variable will point to its global version. PHP has no limit on the maximum number of global variables that a function can declare.

Related Article

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.