I struggled forever trying to figure out the correct way to refer to variables of an include_once or require_once php file from inside a function of anyone PHP class. I got as far as defining global variables…but everything I read seemed to miss one key part, or at least un-emphasize it enough that I missed it: You have to REDECLARE the global variable in the calling PHP before using.

first.php defines a variable with global $puppies.

second.php wants to call that variable in the function CountPuppies. I have to first write my include_once or require_once before that call, then redeclare global $puppies before I do a call like $count = $puppies.