{"id":188,"date":"2012-01-31T20:35:57","date_gmt":"2012-01-31T20:35:57","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=188"},"modified":"2022-02-17T07:14:05","modified_gmt":"2022-02-17T07:14:05","slug":"php-built-in-super-global-variables","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/memory\/php-built-in-super-global-variables","title":{"rendered":"Built In Superglobal Variables"},"content":{"rendered":"<h4>Warning When Using Superglobal Variables<\/h4>\n<p>Hackers often use these to try and inject code etc.\u00a0 When accessing superglobal variables ensure you sanitise them.\u00a0 E.g.<\/p>\n<pre><code>\r\n  $CameFromPage = htmlentities($_SERVER['HTTP_REFERER']);    \/\/htmlentities() converts things like &lt; &gt; \" \\ etc into HTML strings like &amp;lt; so they become harmless.<\/code><\/pre>\n<h4>Superglobal Variables<\/h4>\n<p>Always available in all scopes<\/p>\n<p style=\"padding-left: 30px;\">$GLOBALS<\/p>\n<p style=\"padding-left: 60px;\">References all variables available in global scope<\/p>\n<p style=\"padding-left: 30px;\">$_SERVER<\/p>\n<p style=\"padding-left: 60px;\">Server and execution environment information<\/p>\n<p style=\"padding-left: 30px;\">$_GET<\/p>\n<p style=\"padding-left: 60px;\">HTTP GET variables<\/p>\n<p style=\"padding-left: 30px;\">$_POST<\/p>\n<p style=\"padding-left: 60px;\">HTTP POST variables<\/p>\n<p style=\"padding-left: 30px;\">$_FILES<\/p>\n<p style=\"padding-left: 60px;\">HTTP File Upload variables<\/p>\n<p style=\"padding-left: 30px;\">$_REQUEST<\/p>\n<p style=\"padding-left: 60px;\">HTTP Request variables<\/p>\n<p style=\"padding-left: 30px;\">$_SESSION<\/p>\n<p style=\"padding-left: 60px;\">Session variables<\/p>\n<p style=\"padding-left: 30px;\">$_ENV<\/p>\n<p style=\"padding-left: 60px;\">Environment variables<\/p>\n<p style=\"padding-left: 30px;\">$_COOKIE<\/p>\n<p style=\"padding-left: 60px;\">HTTP Cookies<\/p>\n<p style=\"padding-left: 30px;\">$php_errormsg<\/p>\n<p style=\"padding-left: 60px;\">The previous error message<\/p>\n<p style=\"padding-left: 30px;\">$HTTP_RAW_POST_DATA<\/p>\n<p style=\"padding-left: 60px;\">Raw POST data<\/p>\n<p style=\"padding-left: 30px;\">$http_response_header<\/p>\n<p style=\"padding-left: 60px;\">HTTP response headers<\/p>\n<p style=\"padding-left: 30px;\">$argc<\/p>\n<p style=\"padding-left: 60px;\">The number of arguments passed to script<\/p>\n<p style=\"padding-left: 30px;\">$argv<\/p>\n<p style=\"padding-left: 60px;\">Array of arguments passed to script<\/p>\n<p><a href=\"http:\/\/hk2.php.net\/manual\/en\/reserved.variables.php\" target=\"_blank\" rel=\"noopener noreferrer\">Full descriptions<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning When Using Superglobal Variables Hackers often use these to try and inject code etc.\u00a0 When accessing superglobal variables ensure you sanitise them.\u00a0 E.g. $CameFromPage = htmlentities($_SERVER[&#8216;HTTP_REFERER&#8217;]); \/\/htmlentities() converts things like &lt; &gt; &#8221; \\ etc into HTML strings like &amp;lt; so they become harmless. Superglobal Variables Always available in all scopes $GLOBALS References all [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-memory"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=188"}],"version-history":[{"count":8,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":3230,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/188\/revisions\/3230"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}