PhpCookies About Cookies
logo
Subscribe (full feed)
Enter your email address:
Delivered by FeedBurner
rss
» November 2, 2007 in    posted by koen
rip_php4.jpg
You might have heard it already when you keep up with the PHP news. PHP 4 is outdated,
it is a fact. Why? Because at the end of the year, there will only be updates for major
security leaks in PHP 4.

So start using PHP 5, or wait for PHP 6. There are rumors about it coming.
To help you get started with PHP version 5, I will write down some major differences
between 4 and 5.

PHP 5 is better with Object Oriented Programming (or in short, OOP). It supports it better,
faster, and easier. It makes OOP so much easier, at least, when you need to use it. I don't
use it that much, but I know cases in which it is quite useful (HINT: Big projects).
XML support. Well, actually, it did support XML, but it's now more enhanced. Take for
example the SimpleXML class.

I have this small XML file with the software installed on my Mac (no, this is not true, I don't
have a file like this, I'm just giving an example).

<mac>
<software>
<name>iLife '08</name>
<developer>Apple</developer>
</software>
<software>
<name>iWork '08</name>
<developer>Apple</developer>
</software>
<software>
<name>TextMate</name>
<developer>MacroMates</developer>
</software>
<software>
<name>Skype</name>
<developer>Skype</developer>
</software>
</mac>


Now we call that file software.xml
The following PHP script will display all the names in a list. Requirements? PHP 5, and a
few lines of code.

<?php
$xml = new SimpleXMLElement(file_get_contents("software.xml"));
foreach($xml->software AS $software)
{
echo $software->name . " made by " . $software->developer . "
";
}
?>


It will now display a list with software and it's developer. How easy can parsing XML
become? Automatically included with PHP 5. Oh, btw, I'll be talking more on XML soon.
Obviously, there are way more big changes, and small changes, and middle-sized
changes, but I found these two the most important. Especially XML. I'm love RSS feeds,
and well, they are XML.

Now The Next Step....
Convince your webhost to upgrade to the new version of PHP if they haven't done! Tell
them it's outdated, tell them that PHP 5 is so much better.
If you need to know more, or want to say that you already switched, leave a comment below.




45n5 (946) says on November 3, 2007:
i love php5 for simplexml and the xml parsing. it makes consuming things like most web services pretty easy.