How to access global variable in php ?

If you are in a function on class method scope, you can gain access to a global variable by using a global keyword.$x = 5; function myFunc() { global $x; echo $x; }Remeber that using globals usually isn't a good idea. Better idea would be divide your globals by categories/modules and store it in static variables of some classes.

Comments

Popular posts from this blog

How to construct a B+ tree with example

How to show only month and year fields in android Date-picker?

Visitor Counter Script Using PHP