{"id":136,"date":"2011-12-24T15:01:07","date_gmt":"2011-12-24T15:01:07","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=136"},"modified":"2022-06-23T11:07:17","modified_gmt":"2022-06-23T10:07:17","slug":"using-if-in-php","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/if\/using-if-in-php","title":{"rendered":"If"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Logical OR<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>if (empty($user_id) || in_array($user_id, $banned_list))<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Logical AND<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>if (file_exists($filename) &amp;&amp; filetime($filename) &gt; time())\n{\n}\n<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">Not Equal<\/h5>\n\n\n\n<pre class=\"wp-block-code\"><code>if ($domain !== 'somedomain.com')\n{\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">When return value can be boolean or an integer<\/h4>\n\n\n\n<p>Use if ($ReturnValue === false) or $ReturnValue !== false)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">If with load of a&nbsp;return value into a variable<\/h4>\n\n\n\n<p>Ensure you enclose the assignment in brackets or it won\u2019t work correctly<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\tif (($MyVariable = SomeFunction()) > -1)\n\t{\n\t\t\/\/$MyVariable contains the return value\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Logical OR Logical AND Not Equal When return value can be boolean or an integer Use if ($ReturnValue === false) or $ReturnValue !== false) If with load of a&nbsp;return value into a variable Ensure you enclose the assignment in brackets or it won\u2019t work correctly<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-136","post","type-post","status-publish","format-standard","hentry","category-if"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/136","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=136"}],"version-history":[{"count":6,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/136\/revisions"}],"predecessor-version":[{"id":4298,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/136\/revisions\/4298"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}