PHP 7.4.0 Release Announcement

Listen to the blog audio here!

The fourth feature update to PHP 7 series PHP 7.4 has released and ready to use. The developers have brought significant improvements and new features in this version. PHP 7.4.0 Release Announcement was made by the PHP developer team on 28 November.

So, What’s new in PHP 7.4?


Keep your reading on you are going to know what is PHP 7.4.0 New Features. It could be helpful to you to decide whether you should migrate to PHP 7.4.0 Released version.

Typed Properties

Arrow Functions

Limited Return Type Covariance and Argument Type Contravariance

Unpacking Inside Arrays

Numeric Literal Separator

Weak References

Allow expression from __to String()

Opcache Preloading

Several Deprecations

Extension Removed from the Core

Typed Properties:


Typed properties, features that were missing in PHP development, is now available in its latest version PHP 7.4.0. It is one of the major improvements to PHP’s type system. In PHP 7.4.0, you do not need to create getter and setter methods to enforce type contracts. Also, you can now declare type on static properties, which was not allowed before.

PHP 7.4.0 New Features

Arrow Functions:


Arrow Functions also are known as short-closures that allow using single-line functions that help to write neat and simple code. Arrow Function has access to the parent scope already, and so there is no need for use ().

Limited Return Type Covariance and Argument Type Contravariance:


PHP 7.4.0 enables usage of covariant types and parameter types can substitute for its supertypes where a return type can substitute a subtype.

Unpacking Inside Arrays:


Latest PHP 7.4.0 lets you use spread operators in arrays to make argument unpacking behavior consistent. However, string keys are not supported, and only index arrays can use.

Numeric Literal Separator:


Numeric Literal Separator proposes to improve code readability and support the use of underscores in numeric literal to visually separate groups of digits. Adding underscores in numeric literal will not change the value of digits.

Weak References:


The latest version PHP 7.4.0 supports the weak references too. Such references allow programmers to retain a reference to an object that does not prevent the object from being destroyed. They are useful for implementing caches like structure. To use weak references, you will require to install PECL extension pecl-weakref.

Allow exceptions from __toString():


Now it is permitted to throwing exceptions from __String() in PHP 7.4.0. Previously, throwing an exception from __to String() method resulted in a fatal error. Fatal E_RECOVERABLE_ERROR is converted to Error exception in string conversations.

PHP 7.4.0 New Features

OPcache Preloading:


PHP 7.4.0 has added the support for preloading code. In PHP development, you can always configure OPcache to enhance the performance of PHP 7.4. OPcache prevents the repetition of compilation via compiles the code files and saving them in shared memory. And so, the whole concept of loading files in OPcache is known as preloading that is now added.

Extension Removed from the Core:


Extensions have been moved to the PECL repository of PHP extensions and no longer available in PHP distribution. They have mentioned in manual about PECL package version of these extensions will be created as per user demand.

Several Deprecations:


New things always result in depreciation of the older. So, have a look at below deprecations that are coming along the latest version PHP 7.4.0.

Curly braces used syntax is deprecated. $var{$idx} is now $var[$idx]

(real) cast and is_real() function

Unbinding $this of a non-static closure that uses $this

Parent keyword inside class without parent

allow_url_include INI

Invalid character in base conversation functions like base_convert(), bindec(), octdec() and hexdec() will now generate a deprecation notice

array_key_exist() on objects

Magic quotes functions

convert_cyr_string() deprecated & can be replaced with mb_convert_string(), iconv() or UConverter

money_format() function replaced by intl NumberFormatter functionality

ezmlm_has() function deprecated

restore_include_path() is deprecated & can be replaced by ini_restore

Passing parameters in reverse order to implode() is deprecated. implode($parts, $glue) instead of implode($glue, $parts)

FILTER_SANITIZE_MAGIC_QUOTES is now FILTER_SANITIZE_ADD_SLASHES

Multibyte String

PHP 7.4.0 New Features

So, these were a glimpse of new features and some deprecations of the PHP 7.4.0. I hope it will clarify whether the new version is useful to you and whether you need to hire PHP developers. Though, if you like to dig deeper about PHP 7.4.0, you should check out the official RFC Documents and PHP manual as well.


ABOUT THE AUTHOR
blog Author - kodytechnolab

Drashati Pandya

PHP Developer


RELATED POSTS