I started writing a function and added a few globals to it. Then I came on here to read about some issues using global in PHP functions. I understand some of the reasoning why it's bad but don't fully understand it.
An example of one of the links I read PHP global in functions
For example, I have a config.php file that says the name of the user group for all users to be in. I have a functions.php with a function that requires the $user_group
variable set in the config file. So I do the following:
function user_group_check($_POST['username']) {
global $user_group;
[...code to check if username is in $user_group...]
}
Why would something like this be bad? $user_group is required for the function to even work. So how is using global worse than using `user_group_check($_POST['username'],$user_group) ?