How Can I Create a Global Variable

To create a global variable in PHP, all you have to do is put the keyword global in front of the variable.

If a variable is declared and initialized in a function, it is a local variable,
It can only be utilized in that function

An example of a function is shown in the code below:

Below is the code making this variable global: