New features
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.
Backward Incompatible Changes
Although most existing PHP 5 code should work without changes, please take
note of some backward incompatible changes:
- Safe mode is no longer supported. Any applications that rely on safe mode may need adjustment, in terms of security.
-
Magic quotes has been removed. Applications relying
on this feature may need to be updated, to avoid security issues.
get_magic_quotes_gpc() and get_magic_quotes_runtime()
now always return
FALSE
. set_magic_quotes_runtime() raises anE_CORE_ERROR
level error. - The register_globals and register_long_arrays php.ini directives have been removed.
- Call-time pass by reference has been removed.
- The break and continue statements no longer accept variable arguments (e.g., break 1 + foo() * $bar;). Static arguments still work, such as break 2;. As a side effect of this change break 0; and continue 0; are no longer allowed.
-
In the date and time extension, the timezone can no longer be
set using the TZ environment variable. Instead you have to specify a timezone using the
date.timezone php.ini option or date_default_timezone_set()
function. PHP will no longer attempt to guess the timezone, and will instead fall back to "UTC" and issue
a
E_WARNING
. -
Non-numeric string offsets - e.g. $a['foo'] where $a is a string - now return
false on isset() and true on empty(), and produce a
E_WARNING
if you try to use them. Offsets of types double, bool and null produce aE_NOTICE
. Numeric strings (e.g. $a['2']) still work as before. Note that offsets like '12.3' and '5 foobar' are considered non-numeric and produce aE_WARNING
, but are converted to 12 and 5 respectively, for backward compatibility reasons. Note: Following code returns different result. $str='abc';var_dump(isset($str['x'])); // false for PHP 5.4 or later, but true for 5.3 or less -
Converting an array to a string will now generate an
E_NOTICE
level error, but the result of the cast will still be the string "Array". -
Turning
NULL
,FALSE
, or an empty string into an object by adding a property will now emit anE_WARNING
level error, instead ofE_STRICT
. - Parameter names that shadow super globals now cause a fatal error. This prohibits code like function foo($_GET, $_POST) {}.
- The Salsa10 and Salsa20 hash algorithms have been removed.
-
array_combine() now returns array() instead of
FALSE
when two empty arrays are provided as parameters. -
If you use htmlentities() with asian character sets, it
works like htmlspecialchars() - this has always been the
case in previous versions of PHP, but now an
E_STRICT
level error is emitted.
Deprecated features in PHP 5.4.x
Deprecated functions:
Changed Functions
OpenSSL:
- Added a no padding option to the openssl_encrypt() and openssl_decrypt() functions.
Other changes
- The default character set for htmlspecialchars() and htmlentities() is now UTF-8, instead of ISO-8859-1. Note that changing your output charset via the default_charset configuration setting does not affect htmlspecialchars/htmlentities unless you are passing "" (an empty string) as the encoding parameter to your htmlspecialchars()/ htmlentities() calls. Generally we do not recommend doing this because you should be able to change your output charset without affecting the runtime charset used by these functions. The safest approach is to explicitly set the charset on each call to htmlspecialchars() and htmlentities().
-
E_ALL
now includesE_STRICT
level errors in the error_reporting configuration directive. -
SNMP now has an OOP API.
Functions now return
FALSE
on every error condition including SNMP-related (no such instance, end of MIB, etc). Thus, in particular, breaks previous behavior of get/walk functions returning an empty string on SNMP-related errors. Multi OID get/getnext/set queries are now supported. Dropped UCD-SNMP compatibility code, consider upgrading to net-snmp v5.3+, Net-SNMP v5.4+ is required for Windows version. In sake of adding support for IPv6 DNS name resolution of remote SNMP agent (peer) is done by extension now, not by Net-SNMP library anymore. - OpenSSL now supports AES.
- CLI SAPI doesn't terminate any more on fatal errors when using interactive mode with readline support.
- $_SERVER['REQUEST_TIME_FLOAT'] has been added to include microsecond precision.
- Added new hash algorithms: fnv132, fnv164, joaat
- Chained string offsets - e.g. $a[0][0] where $a is a string - now work.
- Arrays cast from SimpleXMLElement now always contain all nodes instead of just the first matching node. All SimpleXMLElement children are now always printed when using var_dump(), var_export() and print_r().
- It's now possible to enforce the class' __construct arguments in an abstract constructor in the base class.
Thank you ...your blog is very knowledgeable
ReplyDeleteWeb Solution
thanks
Delete