{"id":630,"date":"2012-10-26T08:08:47","date_gmt":"2012-10-26T08:08:47","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=630"},"modified":"2022-02-17T07:14:03","modified_gmt":"2022-02-17T07:14:03","slug":"global-variables","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/memory\/global-variables","title":{"rendered":"Global Variables &#038; Defines"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Variables<\/h4>\n\n\n\n<p>Any variable used inside a function is by default limited to the local function scope. If you want to access a variable used outside of the function\u00a0you need to declare it as global within the function: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nfunction my_function ()\n{\n  global $the_outside_variable;\n\t\t\n  echo $the_outside_variable;\t\t\/\/&lt;&lt;This now works!\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Defines<\/h4>\n\n\n\n<p>No need to declare a define as global in functions, any function can simply use it<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define(\"USER_MIN_AGE\",             16);<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Variables Any variable used inside a function is by default limited to the local function scope. If you want to access a variable used outside of the function\u00a0you need to declare it as global within the function: Defines No need to declare a define as global in functions, any function can simply use it<\/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-630","post","type-post","status-publish","format-standard","hentry","category-memory"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/630","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=630"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/630\/revisions"}],"predecessor-version":[{"id":2153,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/630\/revisions\/2153"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}