Other language-level modifications
1. Calling non-static methods statically in a non-compatible $this context will no longer be supported.
Calling non-static methods statically in a non-compatible $this context will no longer be supported. In this scenario, $this will not be defined, but the call can still be made, but there will be a warning:
class A { public function test() { var_dump($this); } } // Note: Does NOT extend A class B { public function callNonStaticMethodOfA() { A::test(); } } (new B)->callNonStaticMethodOfA(); // Deprecated: Non-static method A::test() should not be called statically // Notice: Undefined variable $this NULL
Note that this situation applies to calls in incompatible contexts. In the above code example, class B and class A have no relationship, so $this is not defined when called.
But if class B inherits from class A, the call is legal.
2. The following reserved words cannot be used as class names, interface names and trait names.
bool int float string null false trueThe following keywords have been reserved for future use and can currently be used without error, but are not recommended.
resourceobject mixed numeric
3. Yield syntax adjustment
When using the yield syntax structure in an expression, parentheses are no longer needed. It is now a right-associative operator with precedence between the "print" and "=>" operators. In some scenarios the behavior will be inconsistent with before.
echo yield -1; echo (yield) - 1; // 之前的语法解释行为 echo yield (-1); // 现在的语法解释行为 yield $foo or die; yield ($foo or die); // 之前的语法解释行为 (yield $foo) or die; // 现在的语法解释行为
Ambiguity can be avoided by using parentheses.
Note: Regarding yield, you can refer to this article by Brother Bird: http://www.laruence.com/2012/08/30/2738.html
4. Others Some adjustments.
Removed ASP format support and script syntax support: <% and <script language=php>
no longer support reference assignment to the result of new. (Thanks to Gazhikaba for sharing the translation)
Removed scope calls to non-static methods in non-compatible $this contexts. Reference materials: https://wiki.php.net/rfc/incompat_ctx. http://www.laruence.com/2012/06/14/2628.html
The ini file no longer supports # beginning For comments, use ;.
$HTTP_RAW_POST_DATA variable has been removed, use php://input instead. https://wiki.php.net/rfc/remove_alternative_php_tags