There are dozens of reasons to switch to PHP 5—not least the fact that, if you're still stuck on PHP 4, the PHP team is about to pull the rug from under your feet. Despite the fact that you may not have a choice in the matter, upgrading comes with a number of bonus new features that can help you write better code and gain access to new functionality that required a fair amount of hacking in previous version. Here's a quick list of 5 personal favourites (with a little help from my Twitter contacts):
1. SimpleXML
Although its name is the source of much frustration—simple is such a relative concept—SimpleXML is a great extension that makes manipulating XML data a breeze. Thanks to its integration with the PHP 5 object model, SXML allows immediate and intuitive access to the contents of an XML document using normal language constructs: your XML document simply becomes a hierarchy of PHP 5 objects that express elements and their attributes. Combine with XSLT for a kick-ass templating system that (a) is based on well-known standards so your development team doesn't have to learn some made-up markup language and (b) really forces you to separate your frontend from the rest of your application.
Bonus features: SXML integrates with Xpath, making complex XML data extraction practically trivial. If you SimpleXML won't do something you need it to, its underpinnings are based on the same library as DOMXML, making swapping between the two a breeze.
2. JSON and SOAP
Web services are all the rage, and blah blah blah. Forget the hype—the reality is that no serious web application can afford to have a single frontend anymore. Your users expect to be able to interface to your code in a multitude of ways and, if you allow them, will come up with new ways you haven't even thought of.
That's why the support for web service functionality built into PHP 5 through the JSON and SOAP interfaces is a boon for developers both because it lets them consume external services—making rich functionality easier to achieve and less expensive—and because it allows them to create interfaces accessible to anyone. Even more importantly, these interfaces make PHP a viable choice for complex backend applications that can be accessed directly from all sorts of Rich Internet development environments like Ajax and Flex.
Bonus functionality: some PHP IDEs (like Zend Studio) are capable of generating WSDL files directly from your PHP source code (thankfully, because writing WSDL files is about as fun as getting a root canal done with a rusty drill). Large vendors, like Adobe and Microsoft, are taking notice of PHP 5's new interoperation capabilities and actually investing in making their products compatible with it and promoting its usage.
3. PDO
I am not entirely sure why, but PDO seems to be one of the great mysteries of PHP 5 (although not as much as SPL—mentioned later in this entry). The idea of accessing multiple databases using a single library is nothing new, of course, but PDO takes an interesting approach to the problem of database abstraction—it only abstracts access to the database, as opposed to the entire interface to it. This means that it doesn't force you to adopt a "lowest-common-denominator" approach in an attempt to make your application function with every possible database, or implement costly abstraction layers. Rather, it allows you to access your database of choice using a simple, consistent interface that promotes good coding practices and provides important functionality like prepared statement and built-in escaping without bogging down your code.
If you are used to DBMS-specific libraries, PDO may seem a little hard to justify until you start using it consistently and find yourself wondering how you managed to live without prepared statements and language-level iterable result sets—to name a couple of the multitude of new features introduced by it.
Bonus features: drivers for all the "popular" DBMS, including MySQL, MSSQL, Oracle and more. Proper, exception-based error reporting.
4. SPL
If I had to pick a favourite-of-favourites in the new features provided by PHP 5, I'd go for the Standard PHP Library. The SPL allows userland code to present itself as one of a number of built-in PHP language elements like arrays. This sounds like little more than a triviality, but the overloading functionality that it provides can be incredibly powerful. The ability to make any object behave like an array—including iteration using foreach()—is perfect for result sets, filtering functionality, and so much more.
SPL is still suffering from a lack of solid documentation, but its functionality is relatively easy to understand, and some articles on its use do exist.
Bonus features: SPL comes with a number of useful built-in classes, such as DirectoryIterator, which makes examining the contents of a directory tolerable, and SimpleXMLIterator, which ties beautifully into SimpleXML. It also implements an enhanced autoloading feature that simplifies dynamic file inclusion considerably. Recursive iterators make for wonderful geek jokes.
5. SQLite
How many times have you wished you could have a cross-platform, portable, powerful, easy-to-use, file-based database system? Perhaps never—but only because you couldn't use SQLite. This simple but full-featured DBMS packs all the punch of MySQL in a format that doesn't require a database server and runs on every platform on which PHP 5 can be compiled. Creating databases is as simple as creating a file, and everything else follows an almost-standard SQL syntax that provides practically everything that you would expect of a modern DBMS—including support for transactions!
SQLite is a perfect choice for data storage where a MySQL database is overkill and a simple text-based file format doesn't provide the performance you need.
Bonus features: SQLite columns are weakly-typed, making it possible to store just about anything. You can also register your PHP functions within the extension and access them from within your SQL statements. SQLite 3 is widely supported by a number of developer technologies, like Flex, making interoperability a breeze. A nice, multiplatform, GUI-based SQLite database editor built using Adobe AIR is readily available.
And much, much more
So, there you have it: five very good reasons to embrace the move to PHP 5. Any one of these five technologies has the potential to revolutionize the way you write code and open up new opportunities for your development efforts.
This is by no means a comprehensive list. Do you have other favourites? Share them below.
Sunday, April 27, 2008
Subscribe to:
Post Comments (Atom)

23 comments:
SPL autoload methods
Interfaces
__set_state
type hinting
LSB in PHP 5.3
I could go on and on, going back to PHP 4 hurts when I have to do it.
Doug
Using PHP native SOAP implementation is a PITA, especially when interoperating with .NET SOAP servers and clients (which use doc/lit wrapped style), because it officially supports only the rpc/encoded style which is almost deprecated, even when PHP5 was released.
Also IIRC many PHP5 stuff is still are marked as "experimental" in the docs, and the documentation is scarce.
Sebastian
@Anonymous No problems so far for me. BTW, you can pass "style" and "use" params to the SoapClient config to use doc/lit (see the docs).
I can't believe that anybody has been using PDO in production without hassles. PDO/PHP Data Access Abstraction Layer XYZ is a nice idea as such but nobody feels responsible for it since 5.0.
For these and 45 more good reasons to use PHP 5, listen to my talk "50 reasons to use PHP 5" at the upcoming php|tek. So stop posting reasons, Marco, or you will run my talk ;-)
Stefan
For me, Exceptions are by far the most interesting news. Reduces my lines of code my 30%. (dont like type hinting and interfaces so much, though)
Not the list I'd have chosen :)
1. Exceptions
2. Public/protected/private support in objects
3. Object passing by handle
4. Much improved performance
5. Maturing frameworks
Never understood the emphasis on SOAP in the PHP 5 certification, as practically all the systems I've had to integrate with in the past 5 years quickly moved from SOAP to REST (if they ever bothered with SOAP in the first place).
SimpleXML ... handy, but continues PHP's long tradition of buggy XML APIs :( Feels like another piece of abandonware, tbh.
PDO ... also handy, but trying to use prepared statements 100% of the time for improved security hurts performance, because of the limitation of only supporting one prepared statement at a time.
Best regards,
Stu
PDO, SOAP and XML handling are all definite selling points for me, as well as real OOP and exceptions. I know SQLite and SPL are great but I haven't had cause to use them in anger yet.
PHP 4 is almost beyond the grave and lots of the problems people had when first upgrading to PHP 5.0 have been eliminated. With 5.3 on the horizon containing the late static binding fix, I can't see any reason to use anything else :)
Exceptions are by far the most interesting news.
BTW, you can pass "style" and "use" params to the SoapClient config .Thanks
Thanks, for this information and news it was very useful to me
deneme
src belgesi src belgeleri
ı have followed your writing for a long time.really you have given very successful information.
In spite of my english trouale,I am trying to read and understand your writing.
And ı am following frequently.I hope that you will be with us together with much more scharings.
I hope that your success will go on.
wery good thanks
I can't believe that anybody has been using PDO in production without hassles. PDO/PHP Data Access Abstraction Layer XYZ is a nice idea as such but nobody feels responsible for it since 5.0.
徵信, 徵信社, 感情挽回, 婚姻挽回, 挽回婚姻, 挽回感情, 徵信, 徵信社, 徵信, 捉姦, 徵信公司, 通姦, 通姦罪, 抓姦, 抓猴, 捉猴, 捉姦, 監聽, 調查跟蹤, 反跟蹤, 外遇問題, 徵信, 捉姦, 女人徵信, 外遇問題, 女子徵信, 外遇, 徵信公司, 徵信網, 徵信, 徵信社, 外遇蒐證, 抓姦, 抓猴, 捉猴, 調查跟蹤, 反跟蹤, 感情挽回, 挽回感情, 婚姻挽回, 挽回婚姻, 感情挽回, 外遇沖開, 徵信, 徵信, 徵信社, 抓姦, 徵信, 徵信社, 外遇蒐證, 外遇, 通姦, 通姦罪, 贍養費, 徵信, 徵信社, 徵信社, 抓姦, 徵信社, 徵信社, 徵信, 徵信, 徵信公司, 徵信社, 徵信, 徵信公司, 徵信社, 徵信社, 徵信社, 徵信社, 徵信社, 徵信公司, 徵信社, 徵信, 徵信, 徵信公司, 女人徵信, 外遇, 外遇, 外遇, 外遇
徵信, 徵信網, 徵信社, 徵信網, 徵信, 徵信社, 外遇, 徵信, 徵信, 徵信社, 抓姦, 徵信, 徵信社, 外遇, 徵信社, 抓姦, 徵信社, 徵信公司, 徵信, 徵信社, 徵信公司, 徵信, 徵信社, 徵信公司, 徵信社, 徵信社, 徵信社, 徵信社, 徵信, 徵信社, 徵信社, 徵信社, 徵信,
I can't believe that anybody has been using PDO in production without hassles. PDO/PHP Data Access Abstraction Layer XYZ is a nice idea as such but nobody feels responsible for it since 5.0.
For me, Exceptions are by far the most interesting news. Reduces my lines of code my 30%. (dont like type hinting and interfaces so much, though)
希望大家都會非常非常幸福~「朵朵小語‧優美的眷戀在這個世界上,最重要的一件事,就是好好愛自己。好好愛自己,你的眼睛才能看見天空的美麗,耳朵才能聽見山水的清音。好好愛自己,你才能體會所有美好的東西,所有的文字與音符才能像清泉一樣注入你的心靈。好好愛自己,你才有愛人的能力,也才有讓別人愛上你的魅力。而愛自己的第一步,就是切斷讓自己覺得黏膩的過去,以無沾無滯的輕快心情,大步走向前去。愛自己的第二步,則是隨時保持孩子般的好奇,願意接受未知的指引;也隨時可以拋卻不再需要的行囊,一路雲淡風輕。親愛的,你是天地之間獨一無二的旅人,在陽光與月光的交替之中瀟灑獨行。
搬家搬家搬家公司 搬家搬家Shade sailnike shoesMBA在职研究生 在职博士徵信社 徵信室內設計室內設計代償房屋貸款信用貸款外遇離婚抓姦外遇蒐證外遇抓姦侵權仿冒應收帳款工商徵信徵信 徵信社外遇徵信徵信社外遇电动隔膜泵自吸泵化工泵离心泵磁力泵螺杆泵水泵隔膜泵气动隔膜泵百家乐 轮盘 21点 德州扑克 百家乐系统 真人娱乐场 百家乐足球德州扑克 电子游戏 英格兰超级联赛 德国甲组联赛 意大利甲组联赛西班牙甲组联赛法国甲组联赛欧冠杯 英超 足球比分 足球彩票 体育彩票 即时比分 免費a片 a片 免費av 色情影片 情色 情色網 色情網站 色情 成人網成人圖片成人影片 18成人 av av女優 avav女優性 情慾 走光 做愛 sex H漫 情色 情趣用品 情色 a片 a片 成人網站 成人影片 情趣用品 情趣用品アダルトアダルト アダルトサイト アダルトサイト 情趣用品搬家搬家服務搬家保障搬家網搬家估價徵信徵信的意義徵信服務徵信報導徵信問答徵信知識婚禮佈置 婚禮佈置
This is the latest and hottest ghd styler ever. If you need a ghd hair straighteners, this is a must buyghd hair straighteners,cheap ghd hair straighteners,pink ghd hair straightenersghd straightenersComme vous pouvez le voir, il s'agit d'une paire de chaussures shox classiquepink ghd hair straighteners . Si vous souhaitez poursuivre la mode, nike shox NZ sont votre meilleu…"Cette paire de Nike Shox Torch est chaud en maintenant la demande.nike chaussurestn chaussures
I can get Tibia Gold cheaply.
Yesterday i bought Tibia Platinum for my brother.
i hope him like it. i will give Tibia coins to him
as birthday present. i like the Tibia money very much.
I usually buy tibia gp and keep it in my store.
Post a Comment