PHP access Global-Superglobals array Variables

PHP access Global-Superglobals array Variables

In this Post We Will Explain About is PHP access Global-Superglobals array Variables With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Manipulating PHP Superglobal VariablesExample

In this post we will show you Best way to implement scope – PHP access global variable in function, hear for References all variables available in global scopewith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Another must read:  Multiple Controllers on Page using Angular Example

PHP $GLOBALS (super global) variable

$GLOBALS is a core PHP super global any palce to use variable which is used to any page access global variables from any module as well as anywhere in the PHP script or other PHP frameworks Like as a Magento,CI,Yii,Laravel..
PHP has all the predefined some array variables.

The List of PHP superglobal variables are as follows:
*-> $GLOBALS
*-> $_SERVER
*-> $_REQUEST
*-> $_POST
*-> $_GET
*-> $_FILES
*-> $_ENV
*-> $_COOKIE
*-> $_SESSION

PHP $GLOBALS variable

<?php  
$supr = 25;  
$temp = 50;  
function subtraction()  
{  
$GLOBALS['v'] = $GLOBALS['temp'] - $GLOBALS['supr'];  
}   
subtraction();  
echo $v;  
?>   

PHP $_SERVER variable

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

 <?php
 echo "PHP $_SERVER variable Developed By Pakainfo.com";
echo "<br>PHP_SELF:";
echo $_SERVER['PHP_SELF'];
echo "<br>SERVER_NAME:";
echo $_SERVER['SERVER_NAME'];
echo "<br>HTTP_HOST:";
echo $_SERVER['HTTP_HOST'];
echo "<br>HTTP_REFERER:";
echo $_SERVER['HTTP_REFERER'];
echo "<br>HTTP_USER_AGENT :";
echo $_SERVER['HTTP_USER_AGENT'];
echo "<br>SCRIPT_NAME :";
echo $_SERVER['SCRIPT_NAME'];
?> 

PHP $_REQUEST variable

 <html>
<body>
<h1>PHP $_REQUEST variable By Pakainfo.com</h1>
<form method="post" id="liveForm" action="<?php echo $_SERVER['PHP_SELF'];?>">
  Name: <input type="text" name="username">
  <input type="submit">
</form>

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // collect username value of input field
    $username = $_REQUEST['username'];
    if (empty($username)) {
        echo "username is empty";
    } else {
        echo $username;
    }
}
?>

</body>
</html> 

PHP $_POST variable

 <html>
<body>
<h1>PHP $_POST variable Example</h1>
<form method="post" id="liveForm" action="<?php echo $_SERVER['PHP_SELF'];?>">
  Client Name: <input type="text" name="username">
  <input type="submit">
</form>
<hr/>
<?php
//using $_POST method 
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // By Pakainfo.com collect your value of input simple field
    $username = $_POST['username'];
    if (empty($username)) {
        echo "username is empty";
    } else {
        echo $username;
    }
}
?>
</body>
</html> 

PHP $_GET variable

 <html>
<body>
<h1>PHP $_GET variable Example</h1>
<?php
echo "Students " . $_GET['livename'] . " at " . $_GET['querystring'];
?>
</body>
</html> 

Example

Another must read:  PHP MySQL Connect Database Script

I hope you have Got What is Global, Superglobal, Session variables – scope and persistance in PHP And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Reply

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