The next version of PHP, which saw its first release candidate today, has some really awesome new features. You can see a complete list of changes in the README, but here are the ones that caught my eye.
Classes
- Support for Traits (i.e., mix-ins; addresses the multiple-inheritance problem).
- Support for chaining from the constructor:
(new Class)->method()
- Support for
Class::{expr}()
syntax. - Closures inherit
$this
from the outer scope. - Added
ReflectionClass::newInstanceWithoutConstructor()
to create a new instance of a class without invoking its constructor. - Added a new typehint:
callable
Improvements
- Array dereferencing and short array syntax:
echo [1, 2, 3][0]
json_encode()
now supports these additional flags:JSON_UNESCAPED_UNICODE
,JSON_BIGINT_AS_STRING
,JSON_NUMERIC_CHECK
,JSON_PRETTY_PRINT
andJSON_UNESCAPED_SLASHES
.- Multibyte support is enabled by default.
- Faster
unserialize()
and ternary operator performance. - IPv6 support.
Fixing the cruft
ext/mysql
,mysqli
andpdo_mysql
now usemysqlnd
by default.- Removed magic quotes, safe mode, register globals, allow call-time pass-by-reference, and more!
- Default character set is now
UTF-8
instead ofISO-8859-1
.