How to declare a global variable in php?

Posted by Editorial Staff | Updated on

Answer: The $GLOBALS array can be used instead:

If you have a set of functions that need some common variables, a class with properties may be a good choice instead of a global:

If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@] Your question and answer will appear on and help other developers.

Related Questions & Answers