2015-07-10: PHP 7 Beta 1 Released
// Strict Standards: Only variables should be passed by reference
$last = array_pop(getArray());
$last = array_pop((getArray()));
- Now errors on both calls.
- Previously, there was no error on the second call.
$array = [0, 1, 2];
foreach ($array as &$val) {
var_dump(current($array));
}
- Prints the value int(0) three times.
- Previously the output was int(1), int(2), and bool(false).
$array = [0, 1, 2];
$ref =& $array; // Necessary to trigger the old behavior
foreach ($array as $val) {
var_dump($val);
unset($array[1]);
}
- Prints all three elements (0 1 2)
- Previously the second element was skipped (0 2).
$array = [0];
foreach ($array as &$val) {
var_dump($val);
$array[1] = 1;
}
- Now iterates over the appended element as well. As such the output of this example will now be "int(0) int(1)".
- Previously it was only "int(0)".
function foo($a, $b, $unused, $unused) {
// ...
}
- Now triggers a compile-time error.
- Previously, I would have been amazed this worked.
function foo($x) {
$x++;
var_dump(func_get_arg(0));
}
foo(1);
- Now prints "2" instead of "1".
function foo($x) {
$x = 42;
throw new Exception;
}
foo("string");
Stack trace:
#0 file.php(4): foo(42)
#1 {main}
Stack trace:
#0 file.php(4): foo('string')
#1 {main}
$i = 0781; // 8 is not a valid octal digit!
- Now compile-errors.
- Previously ignored digits past anything invalid, resulting in 7.
There are now two exception classes: Exception and Error. Both classes implement a new interface Throwable. Type hints in exception handling code may need to be changed to account for this. Some fatal errors and recoverable fatal errors now throw an Error instead. As Error is a separate class from Exception, these exceptions will not be caught by existing try/catch blocks.
- Use ;-style comments instead.
- Use the php://input stream instead
ob_start() no longer issues an E_ERROR, but instead an E_RECOVERABLE_ERROR in case an output buffer is created in an output buffer handler
setcookie() with an empty cookie name now issues a WARNING and doesn't send an empty set-cookie header line anymore
- All curl file uploads must use the curl_file / CURLFile APIs.
- Removed deprecated mcrypt_generic_end() alias in favor of mcrypt_generic_deinit().
- Removed deprecated mcrypt_ecb(), mcrypt_cbc(), mcrypt_cfb() and mcrypt_ofb() functions in favor of mcrypt_encrypt() and mcrypt_decrypt() with an MCRYPT_MODE_* flag.
- Removed the "rsa_key_size" SSL context option in favor of automatically setting the appropriate size given the negotiated crypto algorithm.
- Removed "CN_match" and "SNI_server_name" SSL context options. Use automatic detection or the "peer_name" option instead.
- Rejected RFC 7159 incompatible number formats in json_decode
- string top level (07, 0xff, .1, -.1)
- all levels ([1.], [1.e1])
- Calling json_decode with 1st argument equal to empty PHP string or value that after casting to string is empty string (NULL, FALSE) results in JSON syntax error.
- MySQL
- Fixed bug #65933 (Cannot specify config lines longer than 1024 bytes).
- Listen = port now listen on all addresses (IPv6 and IPv4-mapped).
https://wiki.php.net/rfc/isset_ternary
$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';
$username = $_GET['user'] ?? 'nobody';