{"id":1509,"date":"2008-12-01T14:14:00","date_gmt":"2008-12-01T19:14:00","guid":{"rendered":"http:\/\/blogs.terrorware.com\/geoff\/2008\/12\/01\/php-cheatsheet\/"},"modified":"2008-12-01T14:14:00","modified_gmt":"2008-12-01T19:14:00","slug":"php-cheatsheet","status":"publish","type":"post","link":"https:\/\/blogs.terrorware.com\/geoff\/2008\/12\/01\/php-cheatsheet\/","title":{"rendered":"PHP cheatsheet"},"content":{"rendered":"<p>This post is for PHP stuff that I needed to use, but couldn&#8217;t easily find on the web<\/p>\n<h3>&#8216;pass&#8217; in PHP<\/h3>\n<p>Maybe it&#8217;s bad to start using conventions from other languages, but I find that sometimes the code is more readable if you write an if statement so that nothing happens if the conditon is true and then put the code that will get run often in the else block.\u00c2\u00a0 In python, if you don&#8217;t want anything to happen in a block, you use the pass statement.\u00c2\u00a0 In PHP, you can just leave the block empty:<\/p>\n<blockquote><p> <code><br \/>\nif ( $condition == true) {<br \/>\n\/\/ do nothing.  note that other than the comment<br \/>\n\/\/ there are no statements in this block<br \/>\n}<br \/>\nelse {<br \/>\n\/\/ do stuff<\/code><\/p>\n<p>&#8230;<\/p>\n<p>}<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>This post is for PHP stuff that I needed to use, but couldn&#8217;t easily find on the web &#8216;pass&#8217; in PHP Maybe it&#8217;s bad to start using conventions from other languages, but I find that sometimes the code is more readable if you write an if statement so that nothing happens if the conditon is&hellip; <a class=\"more-link\" href=\"https:\/\/blogs.terrorware.com\/geoff\/2008\/12\/01\/php-cheatsheet\/\">Continue reading <span class=\"screen-reader-text\">PHP cheatsheet<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[63,61,648],"class_list":["post-1509","post","type-post","status-publish","format-standard","hentry","category-note-to-self","tag-php","tag-programming","tag-reference","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4wnIz-ol","_links":{"self":[{"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/1509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/comments?post=1509"}],"version-history":[{"count":0,"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/posts\/1509\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/media?parent=1509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/categories?post=1509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.terrorware.com\/geoff\/wp-json\/wp\/v2\/tags?post=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}