tags:

views:

442

answers:

10

I'm trying to compile a list of new features found in php 5.3. that I have to check out as time permits. I'd like to do this in the order of usefulness of the features.

The question is subjective, that is the point. I want to end up with a list ordered by what the community likes. Such a list would hopefully be useful to many and the I have not been able to find one on SO.

Please name one specific feature per answer, thanks in advance!

What is your favorite new feature in php 5.3?

+1  A: 

I think PHAR, Lambda and namespace. Theses features seems interesting.

It's hard to answer right now cause we ddidn't use it on a whole project and we already find some strange behavior.

I think next versio of PDT will help programming with PHP 5.3.

Brice Favre
Netbeans already offers 5.3 support (at least in the 6.9RC) I love namespaces (but no so much the implementation php uses) and very interested in PHAR. lambdas are also pretty neat. But... that's three features in one post, should've been three posts for this list.
Kris
+24  A: 

My favorite feature is that the magic quotes and register globals have been DEPRECATED.

Now, any fool still using these will get a warning right to their face :)

AlexV
Its ironic that PHP 5.3's biggest achievement is the halfway-removal of a feature.
Ira Baxter
What's really ironic is that despite all the hate php still runs so many of the webs biggest sites.
Kris
@Ira Baxter A kluge is not a feature--it's a liability.
banzaimonkey
@banzaimonkey: at the risk of starting a flame war, I'll note that I think PHP as a whole qualifies as a kluge.
Ira Baxter
@Ira Baxter There's a page for that already ;) http://stackoverflow.com/questions/309300/defend-php-convince-me-it-isnt-horrible
banzaimonkey
Maybe those who still use register_globals will just deactivate E_DEPRECATED-Warnings - I mean, it still "Just Works" ...
giraff
Yes it's working in 5.3 but it will stop working in 6.0. Better change code right now (anyway you can't be a real programmer and still use register_globals!).
AlexV
While i do believe this will eventually lead to a better quality average, I do not consider it a feature. upvote yes, accept as answer no.
Kris
+16  A: 

Lambda lambda lambda! Definitely adds flexibility that was missing before.

Funkatron
`create_function()` is one of the ugliest things I've seen since eval(). Sure you can fake scope by placing variables in string, and build the function with all sorts of crazy, like with for loops appending a string, but it's just... Then along came Anon Functions, and the world is not such a dark place anymore... except for that damn unfriendly 'use' keyword.
bob-the-destroyer
+6  A: 

I can't resist: Clearly, adding GOTO is the biggest thing since sliced bread.

Ira Baxter
Shouldn't it be spaghetti instead of sliced bread? :p
wimvds
just GOTO spaghetti.
DeadMG
GOTO recalls me of batch coding
Rodrigo
Reminds me of BASIC. After testing, it appears these labels must follow ''/[a-z_][a-z0-9_]*/i" naming pattern. Yes, "_" is a valid label (and a valid function and variable name, but that's for another thread). Thankfully, at least it can't begin with a number, `goto 10`. Otherwise, how would you fit in yet another crucial line between 99 and 100? This isn't Apple Basic. Check out the PHP US man page, second comment. Gives me shivers.
bob-the-destroyer
+13  A: 

Late static binding! Finally some sensible way for "normal" inheritance (similar to C or Java).

For example I've created base class that hides all the gory details of accessing the database, object relational mapping, caching etc. and it's child classes define only:

  • name of the table
  • column names
  • parent-child relationships
eyescream
+1 for late static binding.
wimvds
let's see some of that code!
philfreo
@philfreo I have no idea what do you expect :) But here you go: http://dl.dropbox.com/u/709568/stackoverflow/php5.3%20lsb.zip
eyescream
@eyescream, thanks - that's awesome! seems like that should be a part of a larger framework. which PHP framework is most similar to that? Or if you think it should remain a standalone class, is there somewhere you'll maintain it online?
philfreo
@philfreo - glad you like it! I think that http://www.phpactiverecord.org/ is pretty similar ) There is high chance it will never go live!
eyescream
+5  A: 

Definitely Phar files

jordanstephens
Ooooooo... I missed that one. Pardon me while I ooo and ahh some more.
banzaimonkey
+2  A: 

In my opinion the late static binding is one of the feature that I will use the most.

http://ca2.php.net/lsb

With this, it will now be possible to get the maximum out of inheritance.

Thierry
example of where this is helpful?
philfreo
+5  A: 
bob-the-destroyer
+1 for the COM()/DOTNET() bad support, some of my applications still needing asp to run propriety. Have you ever tried debugging something using a COM() object with php? Most of the times php will completly crash or crash apache, or both and the best thing besides hex code error messages, there's nothing ELSE besides that :P
Rodrigo
@Rodrigo: Why even bother using COM/DOTNET to call these? Just wrap your legacy code in a webservice that you call from your PHP scripts and be done with it.
wimvds
@wimvds: The trick is putting together such a thing in a foreign language - something small and compact, easy to build, and acting like a winapi or universal dll accessor/wrapper. Any tips?
bob-the-destroyer
+2  A: 

At first I was happy about Lambda in PHP 5.3 but now after several months of developing with 5.3 in in my day to day work, I found that I rarely use Lambda in PHP. Unlike JavaScript where I use closures ALL THE TIME.

The really most useful feature for me in 5.3 is late static binding. Almost every time I have to develop something in 5.2, I really miss it.

And just to make it complete: The worst idea for 5.3 is GOTO. 'Nuff said.

Techpriester
+3  A: 

PHP's DateTime-Classes for Timezone-aware Timestamps. It existed before but was improved greatly in 5.3.

giraff
This is awesome.
Alix Axel