开发者

What was your favorite feature that was introduced in PHP 5.3? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I'm trying to compile a list of features that were introduced 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 liked.

Such a list would hopefully be useful to开发者_如何学运维 many who need to do historical research then in the years 2012 or 2013 and I have not been able to find one on SO who did this so far.

Please have named one specific feature per answer, thanks in the past!


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 :)


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


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


Definitely Phar files


I realize you said "one" and "likes", but sometimes a single answer doesn't cut it to put opinion into perspective. In the wild, you may not see shared hosting services or dev teams use any added features for years to come, so importance is subjective. These are picked from scanning over PHP's 5.3 changelog. I could be wrong about which version these features first appeared in, but...

  1. ?: Operator: Shortcut to the shortcut: $a = (($a) ? $a : $somethingelse). If $a is loosely false, just resign it to something else: $a = $a ?: $somethingelse; Now just waiting for $a ?= $somethingelse;. Also, it's like the "OR" operator: if($a ?: $somethingelse), evaluates to true if either $a or $somethingelse are true. Redundant, but there.
  2. __callStatic(): Now that specialized Singleton class just reduced to a single universal class probably 5 code lines long.
  3. Per directory ini files: PHP's version of .htaccess files. Though I have yet to experiment with what ini values are allowed to be switched where.
  4. Additional File functions and DNS lookup support for WIN: at least it would be had WIN obeyed your command to create a `symlink`/shortcut without question since you're the user running the script.
  5. array_replace: Whereas $a + $b kept original values, array_replace($a, $b) replaces them.
  6. Mail logging: Logging of all mail() calls to check if you're site has been turned into a spam bot. Though I have yet to test this in the wild to see exactly which mail functions are hooked into (exec()? imap?).

Missed Chances:

  1. [FIXED] Calling a method with the same name as the parent class calls the constructor: This would've been good to know before. I think it seems like a useful "feature".

Dislikes:

  1. Mysqli is still broken.
  2. WIN32api has been abandoned
  3. DOTNET() never improved and still pretty much just a fancy alias for COM(). Rumors of PHP and WIN cooperating are just rumors.


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


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


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜