{"id":128,"date":"2011-12-24T14:53:58","date_gmt":"2011-12-24T14:53:58","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=128"},"modified":"2022-02-17T07:14:05","modified_gmt":"2022-02-17T07:14:05","slug":"php-defines","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/defines\/php-defines","title":{"rendered":"PHP Defines"},"content":{"rendered":"\n<p>You can just create a variable to hold define values like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$SEMAPHORE_KEY = 12345; \n<\/code><\/pre>\n\n\n\n<p>But this is the PHP correct way to define:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define ('AUTHOR_X_ID',        '16');\n\nif ( $author_id != AUTHOR_X_ID )\n{\n\n}\n<\/code><\/pre>\n\n\n\n<p>Define an array<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>define('MY_ARRAY_DEFINE',       array(\n    'chair',\n    'mat',\n    'thing'\n));<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">defined() (ifdef)<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>  if (defined('MY_DEFINE_NAME'))\n    do_something = 1;\n\n\n\n  if (!defined('MY_DEFINE_NAME'))\n    do_something = 1;\n\n\n  if (defined('MY_SITE_NAME'))\n    $MY_SITE_NAME = MY_SITE_NAME;\n  else\n    $MY_SITE_NAME = get_site_url();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can just create a variable to hold define values like this: But this is the PHP correct way to define: Define an array defined() (ifdef)<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-defines"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/128","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=128"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"predecessor-version":[{"id":3802,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/128\/revisions\/3802"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}