PHP各版本特性
2017-12-20 本文已影响0人
倾斜的阳光
链接
PHP 5.3.0 offers a wide range of new features:
- Support for namespaces has been added.
- Support for Late Static Bindings has been added.
- Support for jump labels (limited goto) has been added.
- Support for native Closures (Lambda/Anonymous functions) has been added.
- There are two new magic methods, __callStatic() and __invoke().
Nowdoc syntax is now supported, similar to Heredoc syntax, but with single quotes. - It is now possible to use Heredocs to initialize static variables and class properties/constants.
- Heredocs may now be declared using double quotes, complementing the Nowdoc syntax.
- Constants can now be declared outside a class using the const keyword.
- The ternary operator now has a shorthand form: ?:.
- The HTTP stream wrapper now considers all status codes from 200 to 399 to be successful.
- Dynamic access to static methods is now possible:
PHP 5.4.0 offers a wide range of new features:
- Support for traits has been added.
- Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.
- Function array dereferencing has been added, e.g. foo()[0].
- Closures now support $this.
- <?= is now always available, regardless of the short_open_tag php.ini option.
- Class member access on instantiation has been added, e.g. (new Foo)->bar().
- Class::{expr}() syntax is now supported.
- Binary number format has been added, e.g. 0b001001101.
- Improved parse error messages and improved incompatible arguments warnings.
- The session extension can now track the upload progress of files.
- Built-in development web server in CLI mode.
PHP 5.5.0 offers a wide range of new features:
- Generators added
- finally keyword added
- New password hashing API
- foreach now supports list()
- empty() supports arbitrary expressions
- array and string literal dereferencing
- Class name resolution via ::class
- OPcache extension added
- foreach now supports non-scalar keys
- Apache 2.4 handler supported on Windows
- Improvements to GD
PHP 5.6.0 offers a wide range of new features:
- Constant expressions
- Variadic functions via ...
- Argument unpacking via ...
- Exponentiation via **
- use function and use const
- phpdbg
- Default character encoding
- Large file uploads
- GMP supports operator overloading
- hash_equals() for timing attack safe string comparison
- __debugInfo()
- gost-crypto hash algorithm
- SSL/TLS improvements
- pgsql async support
PHP 7.0.0 offers a wide range of new features:
- Scalar type declarations
- Return type declarations
- Null coalescing operator
- Spaceship operator
- Constant arrays using define()
- Anonymous classes
- Unicode codepoint escape syntax
- Closure::call()
- Filtered unserialize()
- IntlChar
- Expectations
- Group use declarations
- Generator delegation
- Integer division with intdiv()
- Session options
- preg_replace_callback_array()
- CSPRNG Functions
- list() can always unpack objects implementing ArrayAccess
- Class member access on cloning has been added, e.g. (clone $foo)->bar().
PHP 7.1.0 offers a wide range of new features:
- Nullable types
- Void functions
- Symmetric array destructuring
- Class constant visibility
- iterable pseudo-type
- Multi catch exception handling
- Support for keys in list()
- Support for negative string offsets
- Support for AEAD in ext/openssl
- Convert callables to Closures with Closure::fromCallable()
- Asynchronous signal handling
- HTTP/2 server push support in ext/curl
PHP 7.2.0 offers a wide range of new features:
- New object type
- Extension loading by name
- Abstract method overriding
- Sodium is now a core extension
- Password hashing with Argon2
- Extended string types for PDO
- Additional emulated prepares debugging information for PDO
- Support for extended operations in LDAP
- Address Information additions to the Sockets extension
- Parameter type widening
- Allow a trailing comma for grouped namespaces
- proc_nice() support on Windows
- pack() and unpack() endian support
- Enhancements to the EXIF extension
- New features in PCRE
- SQLite3 allows writing BLOBs
- Oracle OCI8 Transparent Application Failover Callbacks
- Enhancements to the ZIP extension