What is superglobal variable in php?

A few predefined factors in PHP are “superglobals”, which implies that they are constantly open, paying little respect to scope – and you can get to them from any capacity, class or record without doing anything uncommon.

We have defined the brief about all superglobal variables.
These are superglobal variable-

  • $GLOBALS
  • $_SERVER
  • $_REQUEST
  • $_POST
  • $_GET
  • $_FILES
  • $_ENV
  • $_COOKIE
  • $_SESSION

PHP $GLOBALS

$GLOBALS is a PHP superglobal variable which is used to access global variables from anywhere in the PHP script.

Paste this code into your text editor and see the result.
For example-

<?php
$example=”global-variable”;
function funcname()
{
global $example;
echo “This is example of” .” “.$example;
}
?>
<html>
<head>
<title>fist title</title>
</head>
<body>
<p><?php funcname(); ?></p>
</body>
</html>

$nbsp;

Output-

This is example of global-variable.

Leave A Comment?

eighteen + thirteen =