Create global variables : GLOBALS « Language Basics « PHP

Create global variables


$somevar = 15;

function addit() { 
    GLOBAL $somevar;
    print "Somevar is $somevar";


Related examples in the same category

1.Set new value into GLOBALS values
2.Looping Through the $GLOBALS Array
3.$GLOBALS with property
4.Accessing Global Variables with the global Statement
5.Modifying a Variable with $GLOBALS
6.Global vs function level
7.Overriding Scope with the GLOBALS Array