PHP 4 didn’t really catch fire in terms of real-world server support until its first major update, version 4.1. Will the same be true of PHP 5, the first point release of which is now in its early beta stages?
PHP 5.1 Beta 1 has been out for ten days, and Beta 2 has just become available. Neither of these releases has yet been announced on php.net, nor has an official list of changes been posted, but if you’re especially curious you can read the detailed breakdown maintained by the developers.
Upon its release in early 2002, PHP 4.1 made some important changes to the language. It was the first release that recommended register_globals be switched off to improve security. The long-named variables like $HTTP_GET_VARS for accessing submitted values securely were replaced with shorter, more convenient superglobal variables like $_GET. All up, PHP 4.1 almost had a greater impact on the way developers used PHP than the major 4.0 release did.
At this stage, PHP 5.1 is not looking to be quite as spectacular. Some enhancements to Perl regular expressions, a few extra array functions… nothing to write home about. But there is one significant enhancement to PHP in 5.1: PHP Data Objects (PDO).
The PDO library lets you access any of an extensive selection of supported databases using a signle set of functions. So not only do you only need to learn one set of functions to write for multiple databases, but you can transition an application to another database without having to change all the functions throughout your code.
PHP developers have been achieving this for years using database abstraction layers, at first homegrown, then open source, and finally official. This is the first time such an abstraction layer will be completely built into PHP, and not a layer of PHP code sitting on top of it, however.
Could this be the killer feature that draws developers to PHP 5.1 when real-world adoption of PHP 5 is still lagging? If you feel like trying out PDO to decide for yourself, a good place to start is the lead developer’s blog.











June 22nd, 2005 at 3:48 am
Lets not forget the new /ext/date, which is a nice enhancement for date/time calculations
June 22nd, 2005 at 6:05 am
I’ve been working on an OO database-abstraction layer for over a month now, and will probably never need it, due to PDO.
So if anyone knows of a PHP-roadmap, could you please direct me there, so I stop creating useless code?
June 22nd, 2005 at 6:05 am
http://www.sebastian-bergmann.de/blog/archives/504-PHP-5.1-Performance.html#extended
June 22nd, 2005 at 7:36 am
As I extensively use ADOdb for DB abstraction, I’m thinking about writing a Facade layer for translation of ADOdb interface to the PDO one. If I ever get the time, that is.
June 22nd, 2005 at 7:49 am
Added array type hinting. (Dmitry)
Finally…we’re starting to head in the right direction. Type hinting!! Now we justneed type hinting for everything else…
June 22nd, 2005 at 8:03 am
@BerislavLopac - no need for the Facade, John claims to have had a driver for PDO in ADOdb for over a year now: http://phplens.com/phpeverywhere/?q=node/view/167
June 22nd, 2005 at 9:43 am
The killer feature is maybe the performance improvement:
http://www.sebastian-bergmann.de/blog/archives/504-PHP-5.1-Performance.html
The added array type hint is also important :)
The next killer feature will be unicode support and maybe the input filtering, but
not in 5.1, afaik.
June 22nd, 2005 at 10:05 am
You forget about spead… The new version is about 4 times faster, and 20% faster with an opcode cache.
June 22nd, 2005 at 10:31 am
As time passes, PHP steps more toward offering the conveniences already available to ColdFusion developers.
June 22nd, 2005 at 11:52 am
Really! An abstraction layer for an abstraction layer, that’s funny. :)
June 22nd, 2005 at 11:53 am
While PDO will abstract the calls that you make to different databases, it won’t serve as a true abstraction layer. Databases still have different types, different ways of dealing with autonumbers / sequences - you’ll still need an abstraction layer if you want to easily port an app from one DB to another….
June 22nd, 2005 at 12:32 pm
Berislav: PDO isn’t a database abstraction layer so much as a data access abstraction layer. PDO is intended to eventually replace the current PHP database extensions, so having ADOdb support it is a logical thing.
June 22nd, 2005 at 6:23 pm
“Really! An abstraction layer for an abstraction layer, that’s funny.”
What’s even funnier is that I’ve heard of a templating system written in PHP. A templating system in a templating system. Amazing.
Oh, and Perl’s had DBI for over 10 years now. PHP is only 10 years behind!
June 23rd, 2005 at 6:26 am
While this is a nice addition, it’s far from a killer feature, yes you can abstract out the interface to the DB, but that is only the tip of the iceberg when it comes to supporting multiple databases from a single application. It’s still not going to help with the fact that to get the most from each DB flavour (MySQL, SQLite, Postgres, MSSQL, Oracle, etc) you’ll have to consider vastly different table designs / structures and very different methods of querying to get the most from each of them. This is what takes the massive bulk of development time up, the interface to the DB itself is minimal in comparison.
June 23rd, 2005 at 7:06 am
PHP 5.0 provided killer feature w/ better support for objects. Once you code using that technology you wonder why anyone would stay in PHP 4.x. Then it becomes super frustrating that most distros don’t provide PHP 5. What I want to know is why don’t the distros upgrade? What’s the problem?
June 23rd, 2005 at 8:19 am
At the end of the ends, PDO and ADODb are 2 completely different things… One is database abstraction layer, and the one is just the unification of the database function calls…
June 23rd, 2005 at 8:55 am
It is not problem of PHP5, it is problem of speed. Without free and working PHPA for PHP5 nobody will use it. eAcc is stil to buggy.
Why so popular language doesn’t have compiled script support in default ver.
June 23rd, 2005 at 9:21 am
Java has had JDBC built-in to the language for a long time. PHP is way behind.
June 23rd, 2005 at 3:13 pm
Java also has a little bit more corporate support.
June 23rd, 2005 at 3:54 pm
FWIW: Fedora Core 4 shipped with php 5.0.4-10 a week or two ago.
June 23rd, 2005 at 8:41 pm
Yikes. Hope they never add input filtering. NEVER. That’s how we get stupid developers saying “Oh, well, input is filtered on my localhost (PHP 5.2), and we tested functionality on PHP 4.1, so you can run it on PHP4.1+”, only for a massive security hole to be in the software due to lack of manual filtering. Therefore, we’d (we as in the people who aren’t ignorant) STILL need to have manual filtering, and the feature would be completely useless to us.
June 23rd, 2005 at 11:30 pm
Well, chances are if you are USING the input filtering, they are using 5.1/2+, and hence, no need to worry about the straglers using php4
June 24th, 2005 at 11:50 am
If you use input filtering there comes two versions of the superglobals. one is clean
and the other is untouched. the native filtering is ouf course a performance improvement.
i’m sure PEAR::PHP_Compat comes with an
simulated filtering for backwards compatibility, if its out.
Another feature is that 5.1 can run sanboxed PHP VMs in combination with PECL::runkit. The extension is not stable but i hope its getting bundled with PHP in near future.
June 25th, 2005 at 6:10 am
dsfsdfsdf
June 25th, 2005 at 6:13 am
I’ve heard so much about - well this is absolute rubish. I have been developing in php for 6 years now, with some co-workers developing in Java.
It is true that Java forces a cetain coding convention and that everyting is OO making maintenance easier - php allows you to do almost anything, mixing OO with conventional coding practices and allowing you apply clever new solutions which big OO frameworks just does not cater for.
Fact: I have build huge enterprise solution with PHP for bluechip corporates, some bigger than the Java ones. When developing large systems using PHP you obviously need good experience in business systems (like with everything else) - PHP is still faster to develop, faster on performance, lower on system resources, and less of a nightmare to maintain(if developed by a professional), one is able to write 10 lines of code in php that is the equivelant of 60 lines of Java or .net - dont take my word for it, just go have a look at the thousands of companies that is switching to PHP - true genius lies in simplicity, always has. PHP is normally used in LAMP thus 99% of the time it would be Mysql anyway
June 25th, 2005 at 6:22 am
On this note - I think all the Coldfusion, Python, Perl and .Net guys are really just fustrated with the idea that PHP still out performs all other scripting languages in most areas - and it just keeps getting better with every new release - as world-wide and Netcraft stats state - especaily with the global open source boom, but guess what LAMP (Linux, Apache, Mysql, PHP) has always been open source - this must be a very new and confusion situation for all the x and current Microsoft developers alike
June 26th, 2005 at 8:14 pm
I’m still baffled as to why people aren’t upgrading to php5. It’s got significant improvements over php4, and no drawbacks. There is really only one thing that’s not backwards-compatable — the object testing / information functions, though those are so rarely used that it can’t possibly be difficult to re-work them.
I’ve yet to find any commonly used php-based application that doesn’t work correctly with php5, and with the benefits it offers, why not do it?
Hell, you can even run php4 and php5 simultaneously, assuming you’re running apache with DSO support.
July 21st, 2005 at 9:54 am
“….PHP still out performs all other scripting languages in most areas…”.
Heh. Time you poor losers got out from under your cabbage leaves and tried the real world. Such comments used to be splashed about blindly supporting the Mac and Mac OSs.
As for v5 on shared servers, there are lots of progs that will break causing probs for the common non-gek web master.
November 2nd, 2005 at 8:53 pm
What about dbx?
November 25th, 2005 at 8:39 am
In Berlin liegt Schnee und PHP5.1 ist erschienen
PHP5.1 released - linked
June 21st, 2006 at 12:37 am
“php allows you to do almost anything, mixing OO with conventional coding practices and allowing you apply clever new solutions which big OO frameworks just does not cater for.”
True, that’s a big reason why most people’s first taste of web development is PHP. It gets the job done faster and easier, and when youre not a Software engineer, it makes you feel talented.
December 16th, 2006 at 10:26 pm
Can someone tell me what is the difference between mysqli and PDO?
I am consdering using MySQL5.x or PostgreSQL database server but I am not sure which to use, PDO or MySQLi?
December 18th, 2006 at 9:26 am
mysqli is a library of PHP functions for connecting to MySQL databases only. The advantage of using mysqli is that you get access to a few extra MySQL-only features. The disadvantage is that it doesn’t provide some of the security features (such as prepared statements) that PDO provides, and if you should change to a different database server (say PostgreSQL), you’ll need to rewrite all your database code to use a different function library.
PDO is a library of PHP objects/functions for connecting to all sorts of databases, including MySQL and PostgreSQL. It provides a number of handy security features, such as prepared statements that will sanitize dynamic values that you wish to include in your database queries (such as user input) automatically. Additionally, it doesn’t tie you to using just one database server. The disadvantage is that it cuts you off from a few advanced features of the particular database you are using, but in most cases these are not features that you will need.
I highly recommend you go with PDO.