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.