Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PHP Variables

PHP provides a set of predefined variables. They may be super-global, and available in any context, such as $_GET; they may also be classic variables, in the global scope, such as $argv.

The set of predefined variables changes with PHP versions: for example, in version 8.0, $phperrormsg was definitely removed.

The set of predefined variables also depended on PHP directives. $HTTP_RAW_POST_DATA depended upon the always_populate_raw_post_data directive.

<?php

    print_r($_GET);
    print_r($argv); // when in CLI
    print_r($GLOBALS);
    
    function foo() {
        global $argc;
    }

?>

Documentation

See Also