note 113705 added to language.variables.superglobals

From: Date: Mon, 18 Nov 2013 21:35:18 +0000
Subject: note 113705 added to language.variables.superglobals
Groups: php.notes 
Request: Send a blank email to php-notes+get-197561@lists.php.net to get a copy of this message
Want to know how to generate a formatted list with all globals (including custom ones)? Check out the code below. <?php // Generate a formatted list with all globals //---------------------------------------------------- // Custom global variable $_CUSTOM $_CUSTOM = array('USERNAME' => 'john', 'USERID' => '18068416846'); // List here whichever globals you want to print // This could be your own custom globals $globals = array( '$_SERVER' => $_SERVER, '$_ENV' => $_ENV, '$_REQUEST' => $_REQUEST, '$_GET' => $_GET, '$_POST' => $_POST, '$_COOKIE' => $_COOKIE, '$_FILES' => $_FILES, '$_CUSTOM' => $_CUSTOM ); ?> <html> <style> <?php // Adjust CSS formatting for your output ?> .left { font-weight: 700; } .right { font-weight: 700; color: #009; } .key { color: #d00; font-style: italic; } </style> <body> <?php // Generate the output echo '<h1>Superglobals</h1>'; foreach ($globals as $globalkey => $global) { echo '<h3>' . $globalkey . '</h3>'; foreach ($global as $key => $value) { echo '<span class="left">' . $globalkey . '[<span class="key">\'' . $key . '\'</span>]</span> = <span class="right">' . $value . '</span><br />'; } } ?> </body> </html> ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/language.variables.superglobals.php Edit -- https://master.php.net/note/edit/113705 Del: integrated -- https://master.php.net/note/delete/113705/integrated Del: useless -- https://master.php.net/note/delete/113705/useless Del: bad code -- https://master.php.net/note/delete/113705/bad+code Del: spam -- https://master.php.net/note/delete/113705/spam Del: non-english -- https://master.php.net/note/delete/113705/non-english Del: in docs -- https://master.php.net/note/delete/113705/in+docs Del: other reasons-- https://master.php.net/note/delete/113705 Reject -- https://master.php.net/note/reject/113705 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197561) next »