We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
What's New in PHP 8.1 and 8.2 - Derick Rethans
Learn about the latest features and improvements in PHP 8.1 and 8.2, including named arguments, enums, type inference, and more, in this comprehensive conference talk.
-
Named arguments are coming to PHP, allowing for more explicit type declaration and better code readability.
Enums in PHP 8.1 are now backed by strings or integers, and can be used to define a set of named values.
The
booltype no longer includesint, and is now a distinct type that is only true/false. Discord responses will be available as an optional parameter in debug backtraces. PHP’srand()function has been updated to use a pseudo-random number generator, and a newrandom_bytes()function has been added. Theshuffle()function can now be used to scramble array elements. Property promotion in PHP 8.2 is enabled by default, allowing for more implicit type conversions. Type inference in PHP 8.2 will automatically infer the types of variables based on their initial assignments. Enums can be used with thevalueproperty to access their underlying values. Thematchstatement is a new keyword in PHP, similar to a switch statement. Union types can combine multiple types into a single type declaration. Intersection types can combine multiple union types into a single type declaration. Named arguments can be used to specify default values for function arguments. Theclosedirfunction no longer returns the directory path, and instead returns an empty string. Thedir()function will now correctly return the directory path. Basic types in PHP 8.2 will be further unified, with fewer implicit conversions. Set types will be added to PHP, allowing for more explicit type declaration. Sensitive parameters will be added to PHP, allowing for more secure debugging. TheParcelabletype is a new type in PHP, which allows for more explicit type declaration. Theminandmaxfunctions will now work correctly with arrays. Theglobfunction will now correctly match directories. Themove_uploaded_filefunction will now correctly handle move operations. Theshell_execfunction will now correctly handle shell commands.