Home / PHP Tips Generated By ChatGPT / Accessing Global Variables in PHP Use $GLOBALS array to access global variables inside functions. Source Code $GLOBALS['varName'] = "Global variable"; function test() { echo $GLOBALS['varName']; } test();