Live data from Hacker News

PHP 5.4.0 released

php.net

71–80 of 103 posts

Re: PHP 5.4.0 released

#71

Big hitters: array dereferencing - $object->method()[$index] is now valid syntax built-in webserver via CLI - php -s - http://php.net/manual/en/features.commandline.webserver.php traits and the insteadof operator - http://php.net/language.oop5.traits.php shortened array syntax - $array = [1, 2, [1, 2, 3], 4]; Finally removed register_globals ;) Default charset of UTF-8! Read all about it! http://www.php.net/manual/en…

Really looking forward to traits. We have some hacks using interfaces and __call that we have been using to try and approximate traits, but the real thing is always much better. :)

I've used traits a few times and in each case replaced it later by either inheritance or moving the functionality into separate classes. I'm not getting the design considerations that call for traits over alternatives. How would one use, and why is it the better option?

Re: PHP 5.4.0 released

#72

Big hitters: array dereferencing - $object->method()[$index] is now valid syntax built-in webserver via CLI - php -s - http://php.net/manual/en/features.commandline.webserver.php traits and the insteadof operator - http://php.net/language.oop5.traits.php shortened array syntax - $array = [1, 2, [1, 2, 3], 4]; Finally removed register_globals ;) Default charset of UTF-8! Read all about it! http://www.php.net/manual/en…

You forgot (new Object)->method()

Re: PHP 5.4.0 released

#75

I see a lot of mentions of zend in extension names, function names.. Could someone elaborate how Zend relates to PHP?

Zend developed the Zend Engine, a virtual machine. PHP4 is based on the Zend engine. Zend is more than just the framework, it literally is the core of PHP.

derp

Re: PHP 5.4.0 released

#76

They also improved the zend engine, CURL extension, added Tokyo cabinet abstract and Berkeley DB Support! Added a couple of hashes, Improved JSON Extension (JSON_NUMERIC_CHECK!) and a whole lot of bug fixes. The UTF-8 part was long overdue, glad they fixed that. I spend a lot of time programming in PHP. Its reputation is pretty bad, but updates like this keep me going!

PHP was my first love (actually my second, after QBasic) when I was a teenager.

Would love to get back into it now that it's a "real" language.

Got any good tips about books on modern PHP programming?

Re: PHP 5.4.0 released

#77
post #24

Closures can now have a `$this` (by default it is the class in which the closure is declared). No more $that = $this hacks :)

There's also Closure::bindTo() [0], which should allow you do do slightly more functional programming, like JavaScript's Function.apply() [1]

[0] http://docs.php.net/manual/en/closure.bindto.php

[1] https://developer.mozilla.org/en/JavaScript/Reference/Global...

Re: PHP 5.4.0 released

#78
post #43

This is a nice list of improvements. As someone who spends a lot of the day in PHP-land, this is going to make me happy. As someone who also controls our entire server stack, waiting for someone else to decide to upgrade will not be a problem :) I'm glad the PHP devs are starting to actually make it a "real" language. It seems like PHP has always been the fat kid bumbling along behind everyone shouting "wait up guys!…

> waiting for someone else to decide to upgrade will not be a problem :) It is sad that a lot of servers are not like this, and PHP 5.4 will take ages to appear, if at all. Heck, I know of a hosting company still using PHP4.

It's not really sad, some administrators don't like immediately upgrading to the latest and greatest version. Anyone running Debian stable will probably not get 5.4 until 2013.

Re: PHP 5.4.0 released

#79
post #71

Earlier quoted context omitted.

Really looking forward to traits. We have some hacks using interfaces and __call that we have been using to try and approximate traits, but the real thing is always much better. :)

I've used traits a few times and in each case replaced it later by either inheritance or moving the functionality into separate classes. I'm not getting the design considerations that call for traits over alternatives. How would one use, and why is it the better option?

Amongst other things, traits are a way to provide interface delegation. Imperfect, but a lot better than the current solutions.

Re: PHP 5.4.0 released

#80
post #76

They also improved the zend engine, CURL extension, added Tokyo cabinet abstract and Berkeley DB Support! Added a couple of hashes, Improved JSON Extension (JSON_NUMERIC_CHECK!) and a whole lot of bug fixes. The UTF-8 part was long overdue, glad they fixed that. I spend a lot of time programming in PHP. Its reputation is pretty bad, but updates like this keep me going!

PHP was my first love (actually my second, after QBasic) when I was a teenager. Would love to get back into it now that it's a "real" language. Got any good tips about books on modern PHP programming?

Books... not so much. I have another idea: you could check out an MVC-framework like codeigniter or CakePHP. There are numerous tutorials about them, and they give you the added benefit of working with an MVC pattern (knowledge you can use in other languages and frameworks as well, such as Ruby on Rails) and working Object Oriented.

In my opinion, a big drawback of PHP is that it's so easy to screw up because it's easy to pick up. There are so many tutorials out there which will let you make a procedural, cross-scripted, sql-injected security liability spaghetti code... Starting with CodeIgniter or CakePHP is not very hard, especially when you have a little understanding on basic programming with PHP. Good luck!

Post reply on HN