{"id":3384,"date":"2020-10-15T10:31:03","date_gmt":"2020-10-15T09:31:03","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=3384"},"modified":"2022-02-17T07:13:47","modified_gmt":"2022-02-17T07:13:47","slug":"compare-strings","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/strings\/compare-strings","title":{"rendered":"Compare Strings"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">== vs === &#8211; IMPORTANT FOR STRINGS!!!!!<\/h4>\n\n\n\n<p>When comparing a string to an integer the string is evaluated as 0!!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  if (\"ABC\" == 0)<\/code><\/pre>\n\n\n\n<p>evaluates true because first &#8220;ABC&#8221; is converted to integer and becomes 0 then it is compared to 0.<\/p>\n\n\n\n<p>Use === if you are comparing non strings to a string value<\/p>\n","protected":false},"excerpt":{"rendered":"<p>== vs === &#8211; IMPORTANT FOR STRINGS!!!!! When comparing a string to an integer the string is evaluated as 0!! evaluates true because first &#8220;ABC&#8221; is converted to integer and becomes 0 then it is compared to 0. Use === if you are comparing non strings to a string value<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-3384","post","type-post","status-publish","format-standard","hentry","category-strings"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/3384","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=3384"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/3384\/revisions"}],"predecessor-version":[{"id":3389,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/3384\/revisions\/3389"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=3384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=3384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=3384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}