Read morePHP 8.1 – Asynchronous and lightweight thread execution: Fibers
PHP 8.1 – Extra return type :noreturn
For any methods or function which are meant to always throw exception or exit the code using things like: exit() or die()
a new return type of: noreturn
was added. The sample usage could be: function iWillAlwaysExit(): noreturn
.
PHP 8.1 – New fsync() function
Synchronize new changes to the file without re-opening the same file again. fsync()
would also throw a warning when the file is not a file pointer. The interface is: fsync(resource $stream): bool
.
PHP 8.1 – MySQLi: binding multiple values
MySQLi is gettng a feature to bind arrays to execute($array)
method in single call. This would apply to standard int
index based arrays and associative arrays.
PHP 8.1 – MySQLi: fetch_column()
New function was added to retrieve first or any other column from the result set to MySQLi
object. This follows the fetchColumn()
method from PDO and behaves in the same manner.
PHP 8.1 – Default MySQLi Error Mode
The default error mode for mysqli
calls is now changed from silent mode to Exception mode. This doesn’t affect PDO
object since PHP Data Object is already throwing Exception by default.
PHP 8.1 – Secured $GLOBALS array
Not much would care about this one, but it’s worth to mention that previously you could override the whole $GLOBALS
variable with your custom data, now you can only modify its keys/aliases.
PHP 8.1 – New octal integer notation
Forget about a case of checking 016 == 16
causing a false response, from now on any octal integer will have to be written in literal notation, which is 0o16
. This only applies to integer types, strings behavior are kept intact.
PHP 8.1 – New feature array_is_list()
Added a new check to array
to see if it contains only an int based keys in natural order (from 0 to n`). Useful when we want to ensure the array is consistent (untouched) and when we want to serialize an array
to json
to format of [0, 1, 2]
instead of object properties.
PHP 8.1 – Support of merging string keys via Spread Operator
Start merging arrays without array_merge()
completely. Spread Operator have now a support of integer types of keys, as well as string types keys. So you can merge your arrays more safe than before. Merge away!
Read morePHP 8.1 – Support of merging string keys via Spread Operator