{"id":560,"date":"2015-02-17T11:25:09","date_gmt":"2015-02-17T11:25:09","guid":{"rendered":"http:\/\/www.muratyaman.co.uk\/wp\/?p=560"},"modified":"2020-04-01T12:48:28","modified_gmt":"2020-04-01T11:48:28","slug":"php-says-nooo-to-my-integer","status":"publish","type":"post","link":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/2015\/02\/php-says-nooo-to-my-integer\/","title":{"rendered":"PHP says &#8220;Nooo&#8221; to my integer"},"content":{"rendered":"<p>Another eye-opener from PHP is the unexpected behaviour of integer filters. Here is a test case class checking &#8220;01&#8221; and &#8220;10&#8221; whether they are integers or not.<\/p>\n<pre lang=\"php\">\r\nclass TestFilters extends PHPUnit_Framework_TestCase\r\n{\r\n\r\n    public function test_filter_int_with_zero_prefix ()\r\n    {\r\n        $result = filter_var('01', FILTER_VALIDATE_INT) !== false;\r\n        \r\n        $this->assertTrue($result);\r\n    }\r\n    \r\n    public function test_filter_int_with_zero_suffix ()\r\n    {\r\n        $result = filter_var('10', FILTER_VALIDATE_INT) !== false;\r\n        \r\n        $this->assertTrue($result);\r\n    }\r\n    \r\n}\r\n<\/pre>\n<p>Refer to: <a href=\"http:\/\/php.net\/manual\/en\/filter.filters.validate.php\">http:\/\/php.net\/manual\/en\/filter.filters.validate.php<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Another eye-opener from PHP is the unexpected behaviour of integer filters.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[26],"class_list":["post-560","post","type-post","status-publish","format-standard","hentry","category-technology","tag-php"],"_links":{"self":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/560","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=560"}],"version-history":[{"count":3,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/560\/revisions"}],"predecessor-version":[{"id":968,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/560\/revisions\/968"}],"wp:attachment":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}