PHP WordPress Global
What's the use of PHP declaring a global variable outside of a function?
I see the WordPress wp-settings.php file in this paragraph:
/* * 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 alread Y set. */global $wp _version, $wp _db_version, $tinymce _version, $required _php_version, $required _mysql_version;require ( Abspath. Wpinc. '/version.php ');
I don't understand, I beg to explain, thank you ^_^
Reply to discussion (solution)
No effect
And I didn't see it in the wp-settings.php.
Global $WP _version, $wp _db_version, $tinymce _version, $required _php_version, $required _mysql_version;
Only
Require (Abspath. Wpinc. '/version.php ');
It doesn't work.
Global
$a = 1;
$b = 2;
function Sum ()
{
Global $a, $b;
$b = $a + $b;
}
Sum ();
Echo $b;
?>
The output of the above script will be "3". After you declare a global variable $a and $b in a function, all references to either variable point to its global version. PHP has no restrictions on the maximum number of global variables a function can declare.