{"id":11,"date":"2008-07-29T13:04:03","date_gmt":"2008-07-29T12:04:03","guid":{"rendered":"http:\/\/www.weeklywhinge.com\/?p=11"},"modified":"2009-09-28T09:48:19","modified_gmt":"2009-09-28T08:48:19","slug":"php-long-variable-names","status":"publish","type":"post","link":"https:\/\/www.weeklywhinge.com\/?p=11","title":{"rendered":"PHP: long variable names"},"content":{"rendered":"<p><strong>edit: as Chris <a href=\"\/?p=11#comment-627\">points out<\/a> in the comments, this doesn&#8217;t hold true for php 5.2. Yah, boo. \ud83d\ude41<\/strong><\/p>\n<p>So using long variable names in php makes a difference to the speed of your code.<\/p>\n<p>It&#8217;s true: try this&#8230;<\/p>\n<blockquote>\n<pre>&lt;?\r\n$s=time();\r\nfor ($c=0; $c &lt; 100000000; $c++) {\r\n$verylongvariablename++;\r\n}\r\nprint time()-$s . \"\\n\";\r\n\r\n$s=time();\r\nfor ($c=0; $c &lt; 100000000; $c++) {\r\n$a++;\r\n}\r\nprint time()-$s . \"\\n\";\r\n\r\n?&gt;<\/pre>\n<\/blockquote>\n<p>This gives me a difference of around 20%.<\/p>\n<p>Of course in the real world you won&#8217;t just be incrementing variables in a tight loop so the difference is essentially irrelevant and I wouldn&#8217;t recommend anyone starts sacrificing readability by shortening variable names, but I thought it was interesting.<\/p>\n<p>Who knows, you might too \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>edit: as Chris points out in the comments, this doesn&#8217;t hold true for php 5.2. Yah, boo. \ud83d\ude41 So using long variable names in php makes a difference to the speed of your code. It&#8217;s true: try this&#8230; &lt;? $s=time(); for ($c=0; $c &lt; 100000000; $c++) { $verylongvariablename++; } print time()-$s . &#8220;\\n&#8221;; $s=time(); for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[69],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-webdev","tag-php"],"_links":{"self":[{"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":5,"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions\/191"}],"wp:attachment":[{"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weeklywhinge.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}