you can't declare "global" outside of a function,
all variables declared outside of functions are "Global" by design
Main Topics
Browse All Topicscan someone please remind me what is the scope of a variable declared global outside of all functions within PHP
i understand what global $count; means inside of a function but don't understand what global $count means outside of all functions - i must be missing something;
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The use of the 'global' keyword outside of a function has no meaning, and should not be used. Any variable declared in the main body of a script (outside a function) is global in scope.
The one caveat is if the script you are viewing is included into another script within a function. For example:
<?php
$myVariable = 1;
function myFunction()
{
include "myScript.php";
}
?>
And then 'myScript.php' is:
<?php
global $myVariable;
echo $myVariable;
?>
This is actually valid. Rarely used, perhaps, but valid.
Business Accounts
Answer for Membership
by: Catcherman16Posted on 2008-08-20 at 06:34:09ID: 22269212
well, at least in java, when you have a global variable outside of all functions, that means that ANY function can use that variable. However, say you use have 2 different fuctions, one called "add" the other "subtract", if you store information in the global variable "total" while in the "add" function, it will NOT hold the same value if you try to use it in another funciton like "subtract"