0

Omitting the Closing tag in PHP Files

At first when I saw the Zend Framework recommendation of omitting the closing tag in PHP files I thought it bizarre and stupid. Afterall, you close every other syntactic character in programming: parenthesis, brackets, HTML tags, ifs, loops, etc. So why wouldn’t you close the PHP tag at the end of the document as well?

The Zend Framework reason is, of course, to white space data from being sent to the browser prematurely, which messes up sending header information to the browser. My first thought was “this is lazy and encourages bad coding.”

But the more I think about it, the more it makes sense. It isn’t laziness, but a fool proof way to prevent a common mistake from happening. And apparently the closing tag isn’t required at all, so why not?

I don’t think I’ll be quick to adopt this practice, but maybe eventually, and maybe as I write new code. We’ll see.

2

MySQL and the Most Useless Feature Ever

While building MySQL database support into the OpenAvanti PHP framework, I came across an interesting quirk in MySQL that I thought must be a bug. Apparently, after submitting a bug report and getting a response from MySQL, it’s a documented feature (and later, referred to as a limitation).

Continue Reading →

0

An Epic Struggle With Portage

Today I embarked on an epic struggle with the Portage package manager attempting to update the packages on my system. After I ran into what can only be described as a phantom package.

Continue Reading →

2

array_to_string in PostgreSQL

This snippet courtesy of Kieran Smith.

Want to get more work done in a single query? Tired of looping through query results to simply build a list of data. How about this?

SELECT
array_to_string(
    ARRAY(
        SELECT name
        FROM projects
        WHERE customer_id = 10
        ORDER BY LOWER(name)
    ), ', '
) AS projects;

What you are doing is building an array from the subquery and then turning it back into a string immediately, so you can display multiple results in a single field. Our results might look something like this:

gnucashweb, Hangar, OpenAvanti, tarmac

Nice!

2

Gentoo Portage Alternative

I just came across an alternative to the http://gentoo-portage.com and http://packages.gentoo.org sites: http://znurt.org/

Nice, clean, beautiful and full of information.

Copyright © 2010 — phup 'n stuff | Site design by Trevor Fitzgerald