Debugging Invalid XML

SimpleXML with all of it’s faults is still a great way to interact with XML. Most of it’s shortcomings are related to debugging and how it handles invalid XML is no exception. Let’s take a look at what happens when we load an invalid XML string: $xml = " <?xml version='1.0'><root><unclosed></root>"; $simple_xml = simplexml_load_string($xml); if ($simple_xml === false) { throw new Exception('Invalid XML'); }...

Read Full Article →

Upgrade from PHP 5.3 to PHP 5.6 on Ubuntu 12.04 LTS

Last week I posted a call to action to help sway Ondřej Surý into continuing to support Ubuntu 12.04 LTS with his amazing PPA for the latest and greatest PHP versions. Ondřej was kind enough to take the time to backport the PPA and without ado, here’s how to get PHP 5.6 running on your Ubuntu 12.04 LTS box! As with any new PPA,...

Read Full Article →

Call to Action: PHP 5.6 on Ubuntu 12.04 LTS

I’m going to take a break from posting code snippets and how-tos to draw attention to the fact that PHP 5.6 may not be coming to Ubuntu 12.04 LTS by way of Ondřej Surý’s amazing PPA. Yes, you can still compile PHP from source, but as you may already know, using a PPA makes life a helluva lot easier. The reason for omitting Ubuntu...

Read Full Article →

Upgrade to PHP 5.6 on Ubuntu 14.04 LTS

PHP 5.6 is finally here and if you’re on Ubuntu 14.04 LTS you’re stuck with an older version of PHP. If you want to take advantage of the new awesomeness, you can do so very easily thanks to a PPA. If you’ve never added a PPA before, you will want to make sure that you have python-software-properties installed so you have the command available....

Read Full Article →

Fizz Buzz in PHP

Fizz buzz is a fairly common screening question to help sniff out non-programmers during the interview process. The task is to print out numbers 1 through 100 but for multiples of 3 print out “Fizz” instead of the number and for multiples of 5 print “Buzz” instead. If the number happens to be divisble by both 3 and 5 print out “FizzBuzz” instead of...

Read Full Article →