Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ PHP 7.0 Upgrade Notes     - CentOS7 Minimal minimize installation and then install the GNOME graphical interface (Linux)

- Hadoop configuration ssh automation of automation (Server)

- Python Multithreaded Programming (Programming)

- Ubuntu 15.04 installation Powercommands 2.0 (Linux)

- C ++ pointer two third memory model (Programming)

- CentOS 6.5 opens the Xmanager Remote Desktop login (Linux)

- Linux firewall iptables beginner tutorial (Linux)

- Drawing from the Android source code analysis View (Programming)

- Oracle 11g principle study Dataguard (Database)

- Basic data types JavaScript type system and the type of packaging (Programming)

- Linux environment RabbitMQ installation and monitoring of plug-in installation (Linux)

- Gitblit adopted Ticket collaborative development model (Linux)

- How to test your MongoDB application upgrade? (Database)

- Ubuntu Backup and Recovery (Linux)

- Open Ubuntu system updates (Linux)

- Python 2.7 installed on CentOS 6.5 (Linux)

- Linux installation is larger than 2TB (UEFI interface) hard disk solution (Linux)

- Sublime Text 3 using summary (Linux)

- CentOS 6.5 makes the LAN http source (Linux)

- Why is better than Git SVN (Linux)

  PHP 7.0 Upgrade Notes
  Add Date : 2016-04-27      
  PHP 7.0.0 beta1 released in bringing compelling performance, but also brought a lot of change in terms of language features. The following LCTT translated from the official upgrade notes, although not an official release, but presumably from the official release of the characteristics have been very different.

1. backward incompatible changes

Language Change

Changes in processing variables

Indirect variables, properties and methods are now left to right reference semantic interpretation. Some examples:

$$ Foo [ 'bar'] [ 'baz'] // explanation do ($$ foo) [ 'bar'] [ 'baz']
$ Foo -> $ bar [ 'baz'] // do interpretation ($ foo -> $ bar) [ 'baz']
$ Foo -> $ bar [ 'baz'] () // do explain ($ foo -> $ bar) [ 'baz'] ()
Foo :: $ bar [ 'baz'] () // do explain (Foo :: $ bar) [ 'baz'] ()
To restore the previous behavior, we need to explicitly increase parentheses:

$ {$ Foo [ 'bar'] [ 'baz']}
$ Foo -> {$ bar [ 'baz']}
$ Foo -> {$ bar [ 'baz']} ()
Foo :: {$ bar [ 'baz']} ()
Global keywords are now only accept simple variables. Like the previous

global $$ foo-> bar;
Now requires the following wording:

global $ {$ foo-> bar};
Before and after the variable or function call in parentheses no longer has any effect. For example, the following code, the function call results in a pass by reference function

function getArray () {return [1,2,3];}
$ Last = array_pop (getArray ());
// Strict Standards: Only variables can be passed by reference
$ Last = array_pop ((getArray ()));
// Strict Standards: Only variables can be passed by reference
Now whether or not the use of parentheses, will throw a strict standard error. It will not be prompted before the call in the second mode.

Array element, or object property is automatically installed to create a reference to the order, the order will be different from the present results. E.g:

$ Array = [];
$ Array [ "a"] = & $ array [ "b"];
$ Array [ "b"] = 1;
var_dump ($ array);
The result is now [ "a" => 1, "b" => 1], and the previous results [ "b" => 1, "a" => 1].

Related RFC:


Changes to list ()

list () is no longer assigned in reverse order, for example:

list ($ array [], $ array [], $ array []) = [1,2,3];
var_dump ($ array);
The result is now $ array == [1, 2, 3], rather than [3, 2, 1]. Note that only the assignment changes in the order, and the assignment remains consistent (LCTT translation: the previous list () behavior is to start from the back of the variable individually, so that the above usage will produce [3,2,1] This results in the .). For example, similar to the following general usage

list ($ a, $ b, $ c) = [1,2,3];
// $ A = 1; $ b = 2; $ c = 3;
It remains current behavior.

No longer allow for the empty list () assignment. We are all valid:

list () = $ a;
list (,,) = $ a;
list ($ x, list (), $ y) = $ a;
list () is no longer supported for string split (previously only supported in some cases). The following code:

$ String = "xy";
list ($ x, $ y) = $ string;
Now the result is: $ x == null and $ y == null (no prompt), and previous results is: $ x == "x" and $ y == "y". In addition, list () now always realized ArrayAccess can handle objects, such as:

list ($ a, $ b) = (object) newArrayObject ([0,1]);
Now the results are: $ a == 0 and $ b == 1. Previous $ a and $ b are null.

Related RFC:


The change foreach

foreach () iteration no longer affect the internal array pointer, array pointer function can be accessed through the series of current () / next () and so on. E.g:

$ Array = [0,1,2];
foreach ($ array as & $ val) {
var_dump (current ($ array));
Now the point value int (0) three times. Previous output is int (1), int (2) and bool (false).

When the array by value iteration, foreach always an array copy operation, any operation in the iteration of the array will not affect the iterative behavior. E.g:

$ Array = [0,1,2];
$ Ref = & $ array; // Necessary to trigger the old behavior
foreach ($ array as $ val) {
var_dump ($ val);
unset ($ array [1]);
We will now print out all three elements (012), and the second element before 1 will skip (02).

When iterative array by reference, modify the array will continue to affect the iteration. However, when PHP is now in position using the number as a key to better safeguard array. For example, adding an array element by reference in the iterative process:

$ Array = [0];
foreach ($ array as & $ val) {
var_dump ($ val);
$ Array [1] = 1;
Iterative now correctly adds elements. As code output is "int (0) int (1)", previously only "int (0)".

Ordinary (not traversable) objects by value or by reference iterations behaves like an array by reference iteration. This is consistent with previous actions, in addition to a little more precise as to improve the position of management.

To traverse the object iterative behavior remains unchanged.

Related RFC: https://wiki.php.net/rfc/php7_foreach

Changes in processing parameters

Two parameters can not be defined function the same name. For example, the following method will trigger a compile-time error:

publicfunction foo ($ a, $ b, $ unused, $ unused) {
// ...
The code should be amended as above using different parameter names, such as:

publicfunction foo ($ a, $ b, $ unused1, $ unused2) {
// ...
func_get_arg () and func_get_args () function no longer returns the parameters passed to the original value, but returns its current value (may be modified). E.g:

function foo ($ x) {
$ X ++;
var_dump (func_get_arg (0));
foo (1);
Printing will be "2" instead of "a." The code should be changed after a call to func_get_arg (s) performed only modify operation.

function foo ($ x) {
var_dump (func_get_arg (0));
$ X ++;
Or modify the parameters should be avoided:

function foo ($ x) {
$ NewX = $ x +1;
var_dump (func_get_arg (0));
Similarly, the exception does not display back to the original value of the transfer function, but the modified value. E.g:

function foo ($ x) {
$ X = 42;
foo ( "string");
Now the results of the stack trace is:

Stack trace:
# 0 file.php (4): foo (42)
# 1 {main}
And before that:

Stack trace:
# 0 file.php (4): foo ( 'string')
# 1 {main}
This does not affect the runtime behavior of your code, it is worth noting that at the time of commissioning will vary.

The same restriction will affect debug_backtrace () function and other tests of function parameters.

Related RFC: https://wiki.php.net/phpng

Changes integer processing

Invalid octal (contains a number greater than 7) now gives compiler error. For example, the following code is no longer valid:

$ I = 0781; // 8 is not a valid octal number!
Previously, invalid number (as well as any number of invalid figures) will simply be ignored. Previous value of $ i is above 7, because the last two digits will be silently discarded.

Binary image with negative displacement now throws an arithmetic error:

var_dump (1 >> - 1);
// ArithmeticError: with negative displacement
When the number of digits to the left of displacement exceeds the width of the integer, the result is always zero.

var_dump (1 << 64); // int (0)
Previous result of the above code is dependent on the CPU architecture used. For example, x86 (including x86-64) the result is int (1), because of their displacement in the range of operands.

Similarly, the shift to the right when the integer digits beyond the width, the result is always 0 or -1 (depending on the sign):

var_dump (1 >> 64); // int (0)
var_dump (-1 >> 64); // int (-1)
Related RFC: https://wiki.php.net/rfc/integer_semantics

Change string handling

A string containing hexadecimal digits will no longer be treated as numbers, it will not be special treatment. See the examples in the new behavior:

var_dump ( "0x123" == "291"); // bool (false) (used to be true)
var_dump (is_numeric ( "0x123")); // bool (false) (used to be true)
var_dump ( "0xe" + "0x1"); // int (0) (formerly 16)
var_dump (substr ( "foo", "0x1")); // string (3) "foo" (formerly "oo")
// Note: I encountered a non-normal digital format
filter_var () can be used to check whether a string contains a hexadecimal digits, or if the string can be converted to an integer:

$ Str = "0xffff";
if (false === $ int) {
thrownewException ( "Invalid integer!");
var_dump ($ int); // int (65535)
Due to the double-quoted strings and HERE documents adds Unicode code point escape format (Unicode Codepoint Escape Syntax), so with invalid sequence "\ u {" now causes an error:

$ Str = "\ u {xyz}"; // Fatal Error: Invalid UTF-8 code point escape sequence
To avoid this, you need to escape the backslash beginning:

$ Str = "\\ u {xyz}"; // correct
However, do not follow {the "\ u" are not affected. The following code does not generate an error, and work the same as before:

$ Str = "\ u202e"; // correct
Related RFC:


Change error handling

There are two exception classes: Exception and Error. Both classes implements a new interface: Throwable. Exception handling code indicating the type may need to be modified to handle this situation.

Some fatal errors and recoverable fatal error now to throw an Error. Since Exception Error is a separate class, these exceptions are not already try / catch block to catch.

Recoverable fatal error is converted to an exception, so they can not handle the error inside quietly ignored. In some cases, the type indicates failure can no longer be ignored.

Now generates a parsing error Error extended ParseError. In addition based on the return value / errorgetlast () before processing, error handling for certain potentially invalid codes eval () should be changed to capture ParseError.

Constructor of inner class in case of failure will always throw an exception. Some of the previous constructor returns NULL or an object unavailable.

Some tips E_STRICT error level changed.

Related RFC:


Other language change

Non-static approach called static call an incompatible $ this context is no longer supported. In this case, $ this is not defined, but it is allowed to call, and with a waste tip. example:

class A {
publicfunction test () {var_dump ($ this);}
// Note: There is no extended from class A
class B {
publicfunction callNonStaticMethodOfA () {A :: test ();}
(New B) -> callNonStaticMethodOfA ();
// Waste: Non-static method A :: test () should not be called statically
// Tip: Undefined variable $ this
Note that this occurs only in the context of calls from not compatible on. If a class B extends from class A, the call will be allowed, without any prompting.

You can not use the following class name, interface name and specific name (case-sensitive):

This is used for class / interface / trait statement, class_alias () and use statement.

In addition, following the class name, interface name and a special name reserved for future use, but the use of fashion does not throw an error:

When the yield sentence structure when used in an expression context, the brackets are no longer required. It is now a priority in the "print" and "=>" right combination between operators. In some cases this can lead to different behavior, for example:

echo yield-1;
// Previously been explained as follows
echo (yield) -1;
// Now be explained as follows
echo yield (-1);
yield $ foo ordie;
// Previously been explained as follows
yield ($ foo ordie);
// Now be explained as follows
(Yield $ foo) ordie;
This situation can be resolved by increasing the brackets.

Remove the ASP (< %) and script (< script language = php >) tag.

RFC: https://wiki.php.net/rfc/remove_alternative_php_tags

Not supported by reference to the results of the new assignment.

It does not support a non-static method within non-compliant $ this context from the call. For details, see: https://wiki.php.net/rfc/incompat_ctx.

It does not support the ini file # style comments. Use; style notes instead.

$ HTTP_RAW_POST_DATA no longer available, use php: // input stream instead.

Changes in the standard library

call_user_method () and call_user_method_array () no longer exists.

When an output buffer is created in the output buffer handler, ob_start () not to issue E_ERROR, but E_RECOVERABLE_ERROR.

Improved zend_qsort (using a hybrid sort algorithm) better performance and renamed zend_sort.

Add static sorting algorithm zend_insert_sort.

Remove fpm-fcgi the dl () function.

setcookie () if the cookie name null will trigger a WARNING, rather than sending an empty set-cookie header.



Removal of support for disabled CURLOPT_SAFE_UPLOAD options. File upload must use all of the curl curl_file / CURLFile API.

Remove $ is_dst parameters from mktime () and gmmktime () in

If the key does not appear in inifile processor, dba_delete () now returns false.

Libgmp now requires version 4.2 or later.
gmp_setbit () and gmp_clrbit () for a negative index returns FALSE, and other functions consistent with GMP.

Remove obsolete alias datefmt_set_timezone_id () and IntlDateFormatter :: setTimeZoneID (). Instead of using datefmt_set_timezone () and IntlDateFormatter :: setTimeZone ().

Increase LIBXML_BIGLINES parser option. Available starting libxml 2.9.0, and adds line numbers in error reporting greater than 16-bit support.

Remove obsolete alias equivalent mcrypt_generic_deinit () of mcrypt_generic_end ().
Remove dead mcrypt_ecb (), mcrypt_cbc (), mcrypt_cfb () and mcrypt_ofb () function, which is equivalent to using MCRYPT_MODE_ * flag mcrypt_encrypt () and mcrypt_decrypt ().

session_start () as an array accept all INI settings. For example, [ 'cache_limiter' => 'private'] sets session.cache_limiter = private. Also supports 'read_and_close' to close the session after the data is read data immediately.
Save Session processor accept validate_sid () and update_timestamp () to verify the existence of the session ID, timestamp update session. For the old user-defined session preservation compatible processors continue.
Increased SessionUpdateTimestampHandlerInterface. validateSid (), updateTimestamp () defined in the interface inside.
session.lazy_write (default is On) the INI settings support writing only when the session data is updated.

Remove opcache.load_comments configuration statements. Now Loading Notes document at no cost, and is always enabled.

Remove "rsa_key_size" SSL context options, given the negotiated encryption algorithm automatically sets the appropriate size.
Remove "CN_match" and "SNI_server_name" SSL context options. Using automatic detection or "peer_name" option instead.

Removal of the / e (PREG_REPLACE_EVAL) support modifier using preg_replace_callback () instead.


Remove setlocale () string category support. Use LC_ * constants instead. instead.
Remove set_magic_quotes_runtime () and its aliases magic_quotes_runtime ().

Refuse json_decode in RFC 7159 is not compatible with the digital format - the top (07, 0xff, .1, -.1) and all layers ([1.], [1.e1])
Json_decode called with one argument is equivalent to an empty string or value of PHP call to convert the empty string (NULL, FALSE) results in JSON format is wrong.

Remove set_socket_blocking (), equal to its alias stream_set_blocking ().

Remove xsl.security_prefs ini option, use XsltProcessor :: setSecurityPrefs () instead.
2. New Features


Increasing the use of packed statement. (RFC: https://wiki.php.net/rfc/group_use_declarations)
Increased merger null operator (??). (RFC: https://wiki.php.net/rfc/isset_ternary)
Support length> = 231 bytes in a string of 64-bit architecture.
Increased Closure :: call () method (only work on the user side of the class).
An increase of \ u {xxxxxx} Unicode code points in a double-quoted string escape format and here the document.
define () now supports an array as a constant value, fixed when a define () does not support an array of negligence when a constant value.
Increasing the comparison operator (< = >), the spaceship operator. (RFC: https://wiki.php.net/rfc/combined-comparison-operator)
To add a similar commission generator coroutines yield from operator. (RFC: https://wiki.php.net/rfc/generator-delegation)
Reserved keywords can now be used in several new context. (RFC: https://wiki.php.net/rfc/context_sensitive_lexer)
An increase of scalar type declarations, and you can use the declare (strict_types = 1) statement strict mode. (RFC: https://wiki.php.net/rfc/scalar_type_hints_v5)
Added support for user-level security encryption side random number generator. (RFC: https://wiki.php.net/rfc/easy_userland_csprng)

Increased based on two opcode cache files (experimental - disabled by default). To enable it, PHP requires the use of --enable-opcache-file to configure and build, then opcache.file_cache = < DIR > configuration directive can be set in php.ini. Secondary cache may be able to improve the performance of the server is restarted or reset during SHM. Alternatively, you can set opcache.file_cache_only = 1 to use the file cache and do not have to SHM (for shared hosting may be useful); set opcache.file_cache_consistency_checks = 0 to disable the file cache consistency check to speed up the loading process, there is a security risk.

When using OpenSSL 1.0.2 and later constructed, adding "alpn_protocols" SSL context option to allow encrypted client / server stream uses ALPN TLS extension to negotiate an alternative agreement. After consultation protocol information can be obtained by stream_get_meta_data () output access.

It adds a ReflectionGenerator class (yield from Traces, the current file / line, etc.).
ReflectionType added a new class to better support the return type and scalar function type declarations. New ReflectionParameter :: getType () and ReflectionFunctionAbstract :: getReturnType () method returns a ReflectionType instance.

Add a new stream context option is only available for Windows to allow the blocked pipe read. To enable this feature, when you create a stream context, passing array ( "pipe" => array ( "blocking" => true)). It should be noted that this option will result in a deadlock pipe buffers, but it will be useful in several command-line scene.

Changes 3. SAPI module

Repair Bug # 65933 (can not be set more than 1024 bytes configuration line).
Listen = port now listen on all addresses (IPv6 and IPv4-mapped).
4. Discontinued Features


Abandoned PHP 4-style build function (that is to build the function name must be the same as the class name).
Abandoned calls to static non-static methods.

Abandoned "capture_session_meta" SSL context options. Encryption-related metadata on the stream resource activities can stream_get_meta_data () return value of access.
5. Change Function

parse_ini_file ():
parse_ini_string ():

Added scan mode INISCANNERTYPED to get .ini values ​​yield type.
unserialize ():

Unserialize function to add a second parameter (RFC: https://wiki.php.net/rfc/secure_unserialize) to specify the acceptable category: unserialize ($ foo, [ "allowed_classes" => [ "MyClass", " MyClass2 "]]);
proc_open ():

Can be proc_open () the maximum number of pipes used in the previous hard-coded to be limited to 16. Now removes this restriction, limited only by the available memory size of PHP.
Only add new configuration options for Windows "blocking_pipes" can be used to read the mandatory blocking sub-process pipeline. This can be used for several command-line application scenarios, but it will lead to a deadlock. In addition, related to the new pipeline stream context options.
array_column ():

This function now supports the array of objects as two-dimensional array. Only public properties are processed, the object used inside __get () dynamic properties must also implement __isset () down.
stream_context_create ()

Now accepts a Windows-only configuration available array ( "pipe" => array ( "blocking" => )) to force the clog pipes read. This option should be used with care, the platform could lead to a deadlock pipeline buffer.
6. New Functions


Added gmp_random_seed ().

Added preg_replace_callback_array function. (RFC: https://wiki.php.net/rfc/preg_replace_callback_array)
Standard. Added integer division intdiv () function. Adding the reset error status error_clear_last () function.

Zlib:. Added deflate_init (), deflate_add (), inflate_init (), inflate_add () function to run incremental and compressed stream / decompression.

7. New classes and interfaces

Expansion and SAPI 8. removed

sapi / aolserver
sapi / apache
sapi / apache_hooks
sapi / apache2filter
sapi / caudium
sapi / continuity
sapi / isapi
sapi / milter
sapi / nsapi
sapi / phttpd
sapi / pi3web
sapi / roxen
sapi / thttpd
sapi / tux
sapi / webjames
ext / mssql
ext / mysql
ext / sybase_ct
ext / ereg
For more details see:

Note: NSAPI did not vote in the RFC, but it will be removed later. That is, it is not available in the future related to the SDK.

9. Extended other changes

Mhash future is not an extension of the use function_exists ( "mhash") to check whether available.
10. New Global Constants

Core. Adding PHP_INT_MIN


These constants are used to control the addition of new incremental deflate_add () and inflate_add () refresh function's behavior:

Remove the T1Lib support, so due to the dependence on T1Lib optional, as the future is unavailable:

imagepsbbox ()
imagepsencodefont ()
imagepsextendedfont ()
imagepsfreefont ()
imagepsloadfont ()
imagepsslantfont ()
imagepstext ()

'Gd PS font'
'Gd PS encoding'

11. INI file processing changes

Remove the asp_tags ini directive. If you enable it causes a fatal error.
Remove the always_populate_raw_post_data ini directive.
12. Windows Support


It supports native 64-bit integers on 64-bit systems.
Support for large files on 64-bit systems.
Support getrusage ().

Ftp extension is always carried by the shared library.
For SSL support, the abolition of the openssl extension dependence instead rely only openssl library. If you have compiled automatically enabled ftp_ssl_connect ().

Odbc extension is always carried by the shared library.
13. Other changes

NaN and Infinity are always converted to an integer 0 instead of undefined and platform-dependent.
On non-target method call will trigger a trappable error instead of a fatal error; see: https://wiki.php.net/rfc/catchable-call-to-member-of-non-object
zend_parse_parameters, prompt and type conversion, now always with "integer" and "float", rather than "long" and "double".
If ignore_user_abort set to true, the corresponding interrupt connection, the output buffer will continue to work.
- Python decorators to learn and practice the actual usage scenarios (Programming)
- Win7 + Ubuntu Kylin + CentOS 6.5 installed three systems (Linux)
- Installation and management of Linux applications (Linux)
- Talk about the Linux folder permissions issue again (Linux)
- Install DB2 V10 and Data Studio V3 under Linux (Ubuntu) environment (Database)
- 4 lvcreate example commonly used commands (Linux)
- Getting the Linux shell flow control statements (Programming)
- How to upgrade to Ubuntu 14.04 Ubuntu 14.10 (Linux)
- CentOS 7 source code to compile and install PHP5.6 Nginx1.7.9 and MySQL (LNMP build environment) (Server)
- grub boot error resolution examples (Linux)
- Python programmers most often committed ten errors (Programming)
- Linux gprof oprofiling and performance testing tools (Linux)
- Ubuntu Gitolite management Git Server code base permissions (Server)
- Linux NFS FTP use (Server)
- Linux system security knowledge (Linux)
- Android View event delivery (Programming)
- Linux learning portal: CentOS 6.4 system kernel upgrade (Linux)
- Use SecureCRT to transfer files between Linux and Windows (Linux)
- mysqldump implement database logical backup (Database)
- Binary search -Java achieve (Programming)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.