{"id":639,"date":"2011-12-19T16:13:07","date_gmt":"2011-12-20T00:13:07","guid":{"rendered":"http:\/\/blog.portnumber53.com\/?p=639"},"modified":"2011-12-19T16:13:07","modified_gmt":"2011-12-20T00:13:07","slug":"php-killer-do-not-do-this-on-your-code","status":"publish","type":"post","link":"https:\/\/blog.portnumber53.com\/index.php\/2011\/12\/19\/php-killer-do-not-do-this-on-your-code\/","title":{"rendered":"PHP Killer: Do not do this on your code"},"content":{"rendered":"<p>Unless you want\/need to kill some time&#8230; do not do the following on your PHP code, or you will be banging your head against the wall:<\/p>\n<p>&nbsp;<\/p>\n<p>1. Use trim() inside empty():<\/p>\n<p>&nbsp;<\/p>\n<p>sample:<\/p>\n<pre>if (!empty(trim($item))) {\n\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>work around:<\/p>\n<pre>$item = trim($item);\n\nif (!empty($item)) {\n\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>2. Typecast a parameter that is sent by reference to a function:<\/p>\n<pre>$random = shuffle((array) $items);<\/pre>\n<p>&nbsp;<\/p>\n<p>workround:<\/p>\n<pre>$items = (array) $items;\n\n$random = shuffle($items);<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unless you want\/need to kill some time&#8230; do not do the following on your PHP code, or you will be banging your head against the wall: &nbsp; 1. Use trim() inside empty(): &nbsp; sample: if (!empty(trim($item))) { } &nbsp; work around: $item = trim($item); if (!empty($item)) { } &nbsp; &nbsp;&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blog.portnumber53.com\/index.php\/2011\/12\/19\/php-killer-do-not-do-this-on-your-code\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-639","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/comments?post=639"}],"version-history":[{"count":0,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/639\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/media?parent=639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/categories?post=639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/tags?post=639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}