{"id":42050,"date":"2021-08-08T04:40:34","date_gmt":"2021-08-08T04:40:34","guid":{"rendered":"https:\/\/www.oracletutoring.ca\/blog\/?p=42050"},"modified":"2021-08-08T04:40:35","modified_gmt":"2021-08-08T04:40:35","slug":"php-strpos-zero-or-false","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/php-strpos-zero-or-false\/","title":{"rendered":"PHP: strpos: zero or false?"},"content":{"rendered":"\n<h2>Self-tutoring about PHP comparisons: the tutor begins&#8230;<\/h2>\n<p>In PHP, == means &#8220;compare for equality&#8221; whereas === means &#8220;compare for same type and equality.&#8221; Sometimes the difference is important.<\/p>\n<p>\nstrpos(longstring, shortstring) tells where, in the longstring, you will find the shortstring. If the shortstring isn&#8217;t in the longstring, <em>false<\/em> is returned. Yet, if the longstring and shortstring are identical, 0 is returned, since they match starting from 0 (strings start at position 0, not 1).<\/p>\n<p>In PHP 0==false is true, but 0===false isn&#8217;t. Therefore, with strpos, === can distinguish between an exact match and no match, but == can&#8217;t.<\/p>\n<p>Source:<\/p>\n<p><a href=\"https:\/\/www.php.net\/manual\/en\/function.strpos.php\">php.net<\/a><\/p>\nJack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.\n","protected":false},"excerpt":{"rendered":"<p>Self-tutoring about PHP comparisons: the tutor begins&#8230; In PHP, == means &#8220;compare for equality&#8221; whereas === means &#8220;compare for same type and equality.&#8221; Sometimes the difference is important. strpos(longstring, shortstring) tells where, in the longstring, you will find the shortstring. &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/php-strpos-zero-or-false\/\"> <span class=\"screen-reader-text\">PHP: strpos: zero or false?<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2955],"tags":[],"class_list":["post-42050","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/42050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=42050"}],"version-history":[{"count":1,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/42050\/revisions"}],"predecessor-version":[{"id":42051,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/42050\/revisions\/42051"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=42050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=42050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=42050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}