{"flag":true,"single":true,"pageTitle":"superglobals in php with explain with output","post":{"id":130,"user_id":"1","slug":"superglobals-in-php-with-explain-with-output-sccs","title":"superglobals in php with explain with output","body":"<p>&nbsp;<\/p>\r\n<p>Some predefined variables in PHP are \"superglobals\", which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special.<\/p>\r\n<p>$x=10;<\/p>\r\n<p>echo $_GLOBALS['x']; <strong>\/\/ access global variables because all variables are global<\/strong><\/p>\r\n<ul>\r\n<li>$_SERVER: Contains information about the server and environment, such as the URL, HTTP headers, and script location.<\/li>\r\n<li>$_GET: Contains variables passed to the current script via the URL parameters.<\/li>\r\n<li>$_POST: Contains variables submitted via an HTML form using the HTTP POST method.<\/li>\r\n<li>$_FILES: Contains information about files uploaded via an HTML form using the HTTP POST method.<\/li>\r\n<li>$_COOKIE: Contains variables stored in the user's browser cookies.<\/li>\r\n<li>$_SESSION: Contains variables that are specific to the current user's session.<\/li>\r\n<li>[OPENSSL_CONF] =&gt; C:\/xampp\/apache\/bin\/openssl.cnf<\/li>\r\n<li>[TMP] =&gt; \\xampp\\tmp&nbsp;&nbsp;<\/li>\r\n<li>[HTTP_HOST] =&gt; localhost<\/li>\r\n<li>[HTTP_CONNECTION] =&gt; keep-alive<\/li>\r\n<li>[HTTP_USER_AGENT] =&gt; Mozilla\/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/77.0.3865.90 Safari\/537.36&nbsp;<\/li>\r\n<li>\r\n<p>[HTTP_ACCEPT] =&gt; text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,application\/signed-exchange;v=b3<\/p>\r\n<\/li>\r\n<li>[HTTP_COOKIE] =&gt; _ga=GA1.1.1951352871.1571924619;<\/li>\r\n<li>[SystemRoot] =&gt; C:\\Windows<\/li>\r\n<li>[COMSPEC] =&gt; C:\\Windows\\system32\\cmd.exe<\/li>\r\n<li>[PATHEXT] =&gt; .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC<\/li>\r\n<li>[WINDIR] =&gt; C:\\Windows<\/li>\r\n<li>[SERVER_NAME] =&gt; localhost&nbsp; &nbsp;<\/li>\r\n<li>[SERVER_ADDR] =&gt; ::1<\/li>\r\n<li>[SERVER_PORT] =&gt; 80<\/li>\r\n<li>[REMOTE_ADDR] =&gt; ::1<\/li>\r\n<li>[DOCUMENT_ROOT] =&gt; C:\/xampp\/htdocs<\/li>\r\n<li>[REQUEST_SCHEME] =&gt; http<\/li>\r\n<li>[SCRIPT_FILENAME] =&gt; C:\/xampp\/htdocs\/test.php<\/li>\r\n<li>[REMOTE_PORT] =&gt; 62305<\/li>\r\n<li>[SERVER_PROTOCOL] =&gt; HTTP\/1.1<\/li>\r\n<li>[REQUEST_METHOD] =&gt; GET<\/li>\r\n<li>[QUERY_STRING] =&gt;<\/li>\r\n<li>[REQUEST_URI] =&gt; \/test.php<\/li>\r\n<li>[SCRIPT_NAME] =&gt; \/test.php<\/li>\r\n<li>[PHP_SELF] =&gt; \/test.php<\/li>\r\n<li>$_REQUEST['nameOfFormField'];&nbsp; &nbsp;\/\/ get form data<\/li>\r\n<li>$_POST['fieldName'];\/\/ if form method is post<\/li>\r\n<li>$_GET['fieldName'];\/\/ get form data if method is get<\/li>\r\n<li>$_FILES \/\/handle files upload etc<\/li>\r\n<li>print_r($_COOKIE); \/\/cookies<\/li>\r\n<li>$_SESSION \/\/sessions<\/li>\r\n<\/ul>","category_id":"1","is_private":"0","created_at":"2023-04-29T08:55:53.000000Z","updated_at":"2023-04-29T08:55:53.000000Z","category":{"id":1,"user_id":"1","name":"PHP","slug":"php-3ius","parent_id":null,"created_at":"2023-03-14T03:58:19.000000Z","updated_at":"2023-03-14T03:58:19.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"&nbsp; Some predefined variables in PHP are \"superglobals\", which means that they are always accessible, regardless of scope - and you can a - superglobals in php with explain with output (Updated: April 29, 2023) - Read more about superglobals in php with explain with output at my programming site [SITE]","categories":[]}