Functions and php include

I intentionally left out globals because they should never be used. Using globals are bad practice resulting in code difficult to test and maintain.