5 ms·
Note this is just Zend's take on what's important in PHP 7: it's not a complete list. A more comprehensive list: - Dual-mode scalar type hints (weak by defaul
by itafroma 12y ago
Note this is just Zend's take on what's important in PHP 7: it's not a complete list.
A more comprehensive list:
- Dual-mode scalar type hints (weak by default, toggleable to strict via a per-file syntax) (https://wiki.php.net/rfc/scalar_type_hints_v5 https://wiki.php.net/rfc/scalar_type_hints_v5)
- Return type declarations (https://wiki.php.net/rfc/return_types https://wiki.php.net/rfc/return_types)
- <=> operator (https://wiki.php.net/rfc/combined-comparison-operator https://wiki.php.net/rfc/combined-comparison-operator)
- Null coalesce operator (??) (https://wiki.php.net/rfc/isset_ternary https://wiki.php.net/rfc/isset_ternary)
- Closure::call (https://wiki.php.net/rfc/closure_apply https://wiki.php.net/rfc/closure_apply)
- Abstract syntax tree (https://wiki.php.net/rfc/abstract_syntax_tree https://wiki.php.net/rfc/abstract_syntax_tree)
- Context sensitive lexer, allowing the use of reserved words in more places (https://wiki.php.net/rfc/context_sensitive_lexer https://wiki.php.net/rfc/context_sensitive_lexer)
- Unicode escape syntax in strings (https://wiki.php.net/rfc/unicode_escape https://wiki.php.net/rfc/unicode_escape)
- A uniform variable syntax (https://wiki.php.net/rfc/uniform_variable_syntax https://wiki.php.net/rfc/uniform_variable_syntax)
- Expectations (https://wiki.php.net/rfc/expectations https://wiki.php.net/rfc/expectations)
- Use declaration grouping (https://wiki.php.net/rfc/group_use_declarations https://wiki.php.net/rfc/group_use_declarations)
- Removal of a ton of long-deprecated features
- Massive speed improvements
You can see everything that's been added to PHP 7 on https://wiki.php.net/rfc https://wiki.php.net/rfc (look under Accepted and Implemented - PHP 7.0)
- arenaninja 12y agoOH man I want that Null coalesce operator so bad...
- smutticus 12y agoI feel like I've needed that since I first started coding PHP 17 years ago!
- AlyssaRowan 12y agoI feel like I want to test what happens if you put values like "", false, " ", 0, an empty array, etc etc etc in front of ??. Because, you know, this is PHP.
- itafroma 12y ago> I feel like I want to test what happens if you put values like "", false, " ", 0, an empty array, etc etc etc in front of ??. All of those would result in the variable being assigned those values: the null check uses the same semantics as is_null(), and the truth table for those values is: $v is_null($v) ------------------ '' FALSE false FALSE ' ' FALSE 0 FALSE [] FALSE If you want to all falsy values to use the fallback value, use the shorthand ternary operator (?:) instead.
- raziel2p 12y agoOnly null will return the default value. http://3v4l.org/jphnq http://3v4l.org/jphnq
- deleted 12y ago[deleted]
- barosl 12y ago...Abstract syntax tree? I didn't know it was implemented without using AST. It surprises me, as I've been always told that ASTs are necessary to implement a compiler. Maybe there seem to be some alternatives?
- itafroma 12y ago> Maybe there seem to be some alternatives? This is not meant to be an endorsement of this method, but PHP <7.0 uses a single-pass compilation where the parser itself does the opcode compilation. A lot of the buggy and quirky behavior PHP exhibits (at least when that behavior is unintentional) is the result of this process. Like a lot of extant PHP, there's no real reason it was done this way: it's just the method Rasmus et al happened to program the original engine, and it's grown organically since then. With the AST, phpng, and the uniform variable syntax, I'd argue PHP7's main feature is finally getting around to correcting the sins of the past.
- imakesnowflakes 12y ago>A lot of the buggy and quirky behavior PHP exhibits (at least when that behavior is unintentional) is the result of this process. A lot? Please stop spreading wrong info. In the words of an internal developer, > It does fix a few minor points with regard to variables vs. expressions, but those aren't particularly important. >"So, really, the whole thing has no direct effect on userland devs. It's an internal rewrite." https://www.reddit.com/r/PHP/comments/2cc9xp/rfc_abstract_syntax_tree/cjeppzf https://www.reddit.com/r/PHP/comments/2cc9xp/rfc_abstract_sy...
- itafroma 12y ago> A lot? Please stop spreading wrong info. In the words of an internal developer, You may disagree with me saying "a lot", and that's fair, but I don't think it's fair to say it's "wrong info" and NikiC's characterization that it has "no direct effect on userland devs" is disingenuous, given the RFC lists several changes to syntax and behavior: https://wiki.php.net/rfc/abstract_syntax_tree#changes_to_syntax_or_behavior https://wiki.php.net/rfc/abstract_syntax_tree#changes_to_syn...