[PHP Learn] PHP learn from the beginning 1
Preface: About 2006, study a period of time of PHP, and then did a download site, and later because of the postgraduate stage with Java, EE-related, so PHP was stranded, PHP these years have undergone a great change, the biggest change is to support the object-oriented.
Now because PHP needs to do something, learn again, start from the beginning!
Local and global scopes: variables declared outside the function have global scope and can only be accessed outside of the function
Global variables for the PHP global keyword global keyword and access function function MyTest () {global $x, $y; $y = $x + $y;
}
MyTest (); Echo $y;? >
PHP also stores all global variables in an array named $globals[index]. The subscript is stored as a variable name, which is also accessible within the function and can be used to update global variables directly.
The above example can be rewritten as: function MyTest () {$GLOBALS [' y ']= $GLOBALS [' x ']+ $GLOBALS [' Y '];}
MyTest (); Echo $y;
?>
The difference between Echo and print: