<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><description>Hate and love are the two sides of the same coin.</description><title>PHP Hater</title><generator>Tumblr (3.0; @phphater)</generator><link>http://phphater.com/</link><item><title>explode()</title><description>&lt;p&gt;My head explodes when I see &lt;a href="http://php.net/manual/en/function.explode.php"&gt;this&lt;/a&gt;. I can the naming is to avoid conflicting with the deprecated &lt;a href="http://us3.php.net/manual/en/function.split.php"&gt;split() &lt;/a&gt;, which was yet another brilliant idea.&lt;/p&gt;</description><link>http://phphater.com/post/37843068980</link><guid>http://phphater.com/post/37843068980</guid><pubDate>Thu, 13 Dec 2012 13:08:00 -0500</pubDate></item><item><title>Annotation</title><description>&lt;p&gt;As if the whole language being a pile of hacks is not enough, PHP community (if there is such thing can be called a community) came up with this idea: let&amp;#8217;s use comment to mark functionality!&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve personally seen this idea in production. But I wasn&amp;#8217;t sure what to make of it until this dude &lt;a href="http://theunraveler.com/blog/2012/php-annotations-are-a-horrible-idea/"&gt;spelled it all out&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Borrowing his tl;dr: code comments should never have an effect on application on functionality or flow.&lt;/p&gt;</description><link>http://phphater.com/post/33771307114</link><guid>http://phphater.com/post/33771307114</guid><pubDate>Wed, 17 Oct 2012 09:37:47 -0400</pubDate></item><item><title>htmlspecialchars()</title><description>&lt;p&gt;From a PHP book, introducing &lt;a href="http://php.net/manual/en/function.htmlspecialchars.php"&gt;htmlspecialchars()&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;"Before long, you’ll find its use becomes second nature."&lt;/p&gt;
&lt;p&gt;As a language created for the web, not much thought went into security in PHP. Therefore the burden is on the user, forever.&lt;/p&gt;</description><link>http://phphater.com/post/33362348236</link><guid>http://phphater.com/post/33362348236</guid><pubDate>Thu, 11 Oct 2012 09:01:02 -0400</pubDate></item><item><title>PHP As A Templating Language</title><description>&lt;p&gt;People credit PHP&amp;#8217;s ability to blend-in with HTML as one of the most important reason for it&amp;#8217;s popularity. So I contemplated it as a templating language today.&lt;/p&gt;
&lt;p&gt;Turns out, PHP is not anywhere near an impressive templating language after all.&lt;/p&gt;
&lt;p&gt;To me, the deal breaker is its inability to achieve &lt;em&gt;&lt;a href="http://jinja.pocoo.org/docs/templates/#template-inheritance"&gt;template inheritance&lt;/a&gt;&lt;/em&gt;, something Python web developers take granted for. In Jinja2 or Django&amp;#8217;s templating language, a template can &amp;#8220;implement&amp;#8221; &lt;em&gt;block&lt;/em&gt;s declared in its parent template, whose code is shared among its children. To the controllers, this mechanism is completely hidden, so they simply use those &amp;#8220;child&amp;#8221; templates to render everything, as if they are full-fledged templates.&lt;/p&gt;
&lt;p&gt;With PHP, intuitively, similar functionality can be done with &amp;#8216;include&amp;#8217; &amp;amp; co. You can take one of two approaches:&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;Top-down. Use a variable in place of the content of the &amp;#8220;child&amp;#8221; template, determine which child template is need and pass it to the parent template.&lt;/li&gt;
&lt;li&gt;Bottom-up. Break up the repeated (&amp;#8220;parent&amp;#8221;) code and include them as needed in the actual content. Of course you&amp;#8217;ll need at least 2 &amp;#8220;include&amp;#8221;s (a header and a footer) in the simplest case&lt;/li&gt;
&lt;/ol&gt;&lt;p&gt;Either way, you get one level of &amp;#8220;inheritance&amp;#8221; done.&lt;/p&gt;
&lt;p&gt;To be fair though, &lt;a href="http://phpti.com/"&gt;a library&lt;/a&gt; is all that&amp;#8217;s need to bring PHP back into the game.&lt;/p&gt;</description><link>http://phphater.com/post/33348901672</link><guid>http://phphater.com/post/33348901672</guid><pubDate>Thu, 11 Oct 2012 00:37:00 -0400</pubDate></item><item><title>Appending elements to array</title><description>&lt;p&gt;This is a fun one.&lt;/p&gt;
&lt;p&gt;To add an new element to an array, you do&lt;/p&gt;

&lt;p&gt;$some_array[] = &amp;#8220;new thing&amp;#8221;;&lt;/p&gt;

&lt;p&gt;Speaking of borrowing syntax from C, this is very innovative.&lt;/p&gt;</description><link>http://phphater.com/post/33296695260</link><guid>http://phphater.com/post/33296695260</guid><pubDate>Wed, 10 Oct 2012 09:23:10 -0400</pubDate></item><item><title>Namespace</title><description>&lt;p&gt;I started with PHP 5.4.4, so the 15 years (1994-2009) it took for namespace to arrive didn&amp;#8217;t affect me at all.&lt;/p&gt;
&lt;p&gt;However, &lt;/p&gt;
&lt;p&gt;&lt;em&gt;backslashes&lt;/em&gt;, really?&lt;/p&gt;

&lt;p&gt;Oh it&amp;#8217;s just like file paths, in MS Windows!&lt;/p&gt;</description><link>http://phphater.com/post/33261994601</link><guid>http://phphater.com/post/33261994601</guid><pubDate>Tue, 09 Oct 2012 19:37:48 -0400</pubDate></item><item><title>Base Conversion</title><description>&lt;p&gt;On a second look, the integer base conversion utilities provided by PHP is actually pretty practical. So this may belong to hypercritical territory.&lt;/p&gt;
&lt;p&gt;The issues always come down to interface. For example, parsing hexadecimal, octal or binary strings to integer with &lt;a href="http://php.net/manual/en/function.hexdec.php"&gt;hexdec()&lt;/a&gt;, &lt;a href="http://php.net/manual/en/function.octdec.php"&gt;octdec()&lt;/a&gt; and &lt;a href="http://php.net/manual/en/function.bindec.php"&gt;bindec()&lt;/a&gt; does cover the common cases succinctly, but this interface is far from &lt;a href="http://docs.python.org/library/functions.html#int"&gt;being&lt;/a&gt; &lt;a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt"&gt;elegant&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;These three functions each has a counterpart that converts an integer to a string corresponding to its base. However, the same thing can be accomplished by &lt;a href="http://php.net/manual/en/function.base-convert.php"&gt;base_convert()&lt;/a&gt;, if you allow a little integer-to-string magic happen for the first passed argument.&lt;/p&gt;
&lt;p&gt;TL;DR: practical, ugly, redundant.&lt;/p&gt;</description><link>http://phphater.com/post/31973862185</link><guid>http://phphater.com/post/31973862185</guid><pubDate>Fri, 21 Sep 2012 02:41:00 -0400</pubDate></item><item><title>strtotime()</title><description>&lt;p&gt;strtotime() converts string to PHP objects representing time. Without a doubt, this is a powerful feature in PHP.&lt;/p&gt;
&lt;p&gt;In fact, it is so magical that &lt;a href="https://www.google.com/#hl=en&amp;amp;output=search&amp;amp;sclient=psy-ab&amp;amp;q=strtotime+php"&gt;nobody&lt;/a&gt; can list off all the formats it understands. Of course there&amp;#8217;s a &lt;a href="http://www.php.net/manual/en/datetime.formats.php"&gt;four-part manual &lt;/a&gt;that explains it in whole. Just memorize that and you&amp;#8217;ll be sure your time string is acceptable for strtotime()!&lt;/p&gt;</description><link>http://phphater.com/post/31892044461</link><guid>http://phphater.com/post/31892044461</guid><pubDate>Wed, 19 Sep 2012 20:35:51 -0400</pubDate></item><item><title>mt_rand()</title><description>&lt;p&gt;This is truly random.&lt;/p&gt;
&lt;p&gt;Besides &lt;a href="http://php.net/manual/en/function.rand.php"&gt;rand()&lt;/a&gt;, PHP has another function that generates random integers: &lt;a href="http://php.net/manual/en/function.mt-rand.php"&gt;mt_rand()&lt;/a&gt;. The latter takes advantage of a algorithm called &lt;a href="http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html"&gt;Mersenne Twister&lt;/a&gt; which is more effective/less efficient than the generator in libc, which rand() uses.&lt;/p&gt;

&lt;p&gt;Language interface polluted with implementation details in a irreplaceable way? That&amp;#8217;s a good reason to hate. &lt;/p&gt;</description><link>http://phphater.com/post/31800610433</link><guid>http://phphater.com/post/31800610433</guid><pubDate>Tue, 18 Sep 2012 12:36:06 -0400</pubDate></item></channel></rss>
