For questions specific to the usage and new features of PHP 8. Also, include the more generic [php] tag when using this tag.
PHP 8 is the current major version of php, released on 26 November 2020. It succeeded php-7.4, which was the last release of PHP 7. There is a migration guide to assist with upgrading and a complete list of changes.
New features
- Named arguments in function signatures
- Union types and the mixedtype in function signatures and property declarations
- A new matchexpression, similar toswitchbut which performs strict comparisons and evaluates to an expression
- Constructor property promotion for simplified class declarations
- New string functions str_starts_with(),str_ends_with(), andstr_contains()
- catchstatements do not require a capturing variable, and- throwcan now be used as an expression
- A new nullsafe operator for safe property access
- Attributes used in place of docblocks for structural information
See a high-level overview of new features or a complete list as part of the migration guide.
Removed features
These features were deprecated in previous releases and removed in PHP 8.0
- Old PHP 4-style constructors (methods with the same name as the class)
- The ability to call non-static methods statically
- The track_errorsphp.ini directive
- The __autoload()magic function
- The ability of the @operator to silence fatal errors
- "Leading numeric" strings (i.e. 345 == "345abc"now evaluates to false)
- Use the saltargument topassword_hash().
- The create_function()function
- The each()function
- The read_exif_data()function
- The money_format()function
- The use of array_key_exists()with objects
A complete list of removals and other backwards-incompatible changes can be found as part of the migration guide.
 
     
     
     
     
     
     
     
     
     
     
     
     
    