PHP $GLOBALS

PHP

Hi friends,

PHP $GLOBALS is a php super global variable. We can access this variable any where in the page(that is any functions or methods in the page) and they do not persist between php pages(like SESSION).

$GLOBALS is an associative array and its index holds the name of the variable.

Example:

 <?php
      $GLOBALS['name'] = 'hardycodes';
      function datas(){
          echo 'Name is : '.$name;
      }
      datas();
  ?>  

Leave a Reply

Your email address will not be published. Required fields are marked *