Why are some programming languages so popular while others are seldom used for project development and sometimes even fall into oblivion? There are plenty of reasons for that. The simplicity of syntax, functionality, development network, and community support affect the demand level for each technology.
As the world of IT is constantly developing, coding technologies have to keep pace with the changing environment by providing new features, updates, and enhancements. This is one of the most important elements of language success.
In our company, I enjoy PHP due to the frequent improvements being performed each year and believe that it will be popular for many years to come. Since the release of PHP 5 in 2004, its performance has doubled and perhaps, even tripled. This is one of the reasons why we use PHP in our software development company.
In just 7 days, on Thursday, November 28th, we’ll see the new release of PHP — PHP 7.4, which will become one of the most feature-packed versions ever. In this article, I will list and cover the updated features overview of PHP 7.4. Let’s get started!
What’s new in PHP 7.4? PHP features list
1. Arrow functions’ support
Since anonymous functions, or closures, are mainly applied in JS, they seem to be verbose in PHP. Their implementation and maintenance procedures are also more complex.
The introduction of arrow functions’ support will enable PHP developers to dramatically clean up their code and make the syntax more concise. As a result, you will get a higher level of code readability and simplicity. Take a look at the example below.
So, if you previously had to write this piece of code:
Thanks to the ability to create neat, shorter code, the web development process will go faster, allowing you to save time.
2. Typed properties’ support
The introduction of typed properties in the next release will likely be considered one of the most important updated PHP features. While previously there was no possibility to use declaration methods for class variables and properties (including static properties), now programmers can easily code it without creating specific getter and setter methods.
Due to declaration types (excluding void and callable), you can use nullable types, int, float, array, string, object, iterable, self, bool, and parent.
If a web developer tries to assign an irrelevant value from the type, for instance, declaring $name as string, he or she will get a TypeError message.
Like arrow functions, typed properties also let PHP engineers make their code shorter and cleaner
The main purpose of this cool new feature is to increase PHP 7.4 performance. Simply put, preloading is the process of loading files, frameworks, and libraries in OPcache and is definitely a great addition to the new release. For example, if you use a framework, its files had to be downloaded and recompiled for each request.
When configuring OPcache, for the first time these code files participate in the request processing and then they are checked for changes each time. Preloading enables the server to load the specified code files into shared memory. It’s important to note that they will be constantly available for all subsequent requests without additional checks for file changes.
It is also noteworthy to mention that during preloading, PHP also eliminates needless includes and resolves class dependencies and links with traits, interfaces, and more.
4. Covariant returns & contravariant parameters
At the moment, PHP has mostly invariant parameter types and invariant return types which presents some constraints. With the introduction of covariant (types are ordered from more specific to more generic) returns and contravariant (types are ordered from more generic to more specific) parameters, PHP developers will be able to change the parameter’s type to one of its supertypes. The returned type, in turn, can be easily replaced by its subtype.
5. Weak References
In PHP 7.4, the WeakReference class allows web developers to save a link to an object that does not prevent its destruction. Don’t confuse it with the WeakRef class of the Weakref extension. Due to this feature, they can more easily implement cache-like structures.
See the example of using this class:
<?php$obj = new stdClass;$weakref = WeakReference::create($obj);var_dump($weakref->get());unset($obj);var_dump($weakref->get());?>
Also, note that you can’t serialize Weak References.
6. Coalescing assign operator
A coalesce operator is another new feature available in PHP 7.4. It’s very helpful when you need to apply a ternary operator together with isset(). This will enable you to return the first operand if it exists and is not NULL. If not, it will just return the second operand.
Here is an example:
<?php// Fetches the value of $_GET['user'] and returns 'nobody'// if it does not exist.$username = $_GET['user'] ?? 'nobody';// This is equivalent to:$username = isset($_GET['user']) ? $_GET['user'] : 'nobody';// Coalescing can be chained: this will return the first// defined value out of $_GET['user'], $_POST['user'], and// 'nobody'.$username = $_GET['user'] ?? $_POST['user'] ?? 'nobody';?>
7. A spread operator in array expression
PHP 7.4 will give engineers the ability to use spread operators in arrays that are faster compared to array_merge. There are two key reasons for that. First, a spread operator is considered to be a language structure and array_merge is a function. The second reason is that now your compile-time can be optimized for constant arrays. As a consequence, you will have increased PHP 7.4 performance.
Take a look at the example of argument unpacking in array expression:
Also, it will be possible to expand the same array multiple times. Furthermore, since normal elements can be added before or after the spread operator, PHP developers will be able to use its syntax in the array.
8. A new custom object serialization mechanism
In the new version of PHP, two new methods become available: __serialize and __unserialize. Combining the versatility of the Serializable interface with the approach of implementing __sleep / __ wakeup methods, this serialization mechanism will allow PHP developers to avoid customization issues associated with the existing methods. Find out more information about this PHP feature.
9. Reflection for references
Libraries, such as symfony/var-dumper, heavily rely on ReflectionAPI to accurately display variables. Previously, there was no proper support for reference reflection, which forced these libraries to rely on hacks to detect references. PHP 7.4 adds the ReflectionReference class which solves this problem.
10. Support for throwing exceptions from __toString()
Previously there was no ability to throw exceptions from the __toString method. The reason for that is the conversion of objects to strings is performed in many functions of the standard library, and not all of them are ready to “process” exceptions correctly. As part of this RFC, a comprehensive audit of string conversions in the codebase was carried out and this restriction was removed.
In just a week, PHP 7.4 will be released. There are plenty of new PHP features that reduce memory usage and greatly increase PHP 7.4 performance. You will gain the ability to avoid some previous limitations of this programming language, write cleaner code, and create web solutions faster.
Does PHP, or Hypertext Preprocessor need any introduction? After reigning for more than a decade as the most popular web language that has been integral to the development of many world-famous CMS solutions, PHP is almost everywhere, in every nook and corner of the web. Naturally, when such a language gets a new update, it makes big news. Well, the launch of new PHP 7.4 is almost around the corner. After PHP 7.3 was released in April this year with several improvements in security and performance, now we have got PHP 7.4 Alpha and Beta versions.
Each subsequent PHP version is expected to be a bit faster than the earlier one. The official benchmarks from PHP say that the PHP 7.3 is at least 10% faster than earlier PHP 7.2 version and it comes as a clear proof of why a new PHP upgrade generates so much hope for a PHP development company. After all, PHP is elementary to WordPress and a host of other web languages, CMS solutions, and frameworks.
What PHP 7.4 Will Bring?
Looking back to the earlier version release, it was mainly about boosting performance and delivering a better syntax when PHP 7.3 was released. But then the new version also gave us more readability and maintainability of the code. We already see the new PHP 7.4 is following the same principles making code far less redundant, more reliable and faster in response time.
We have already got the PHP 7.4 Alpha and Beta versions out and before the final release, they gave me enough to figure out the offerings. In a nutshell, PHP 7.4 will provide us a lot of enhancements to use PHP better for all sorts of development tasks.
Let’s have a look at the key offerings of this new PHP update.
1) Arrow Functions
The arrow functions which are also called short functions will give developers more ease as they now need to write shorter code for functions in PHP. Arrow functions allowing only a single expression that also works as the return statement become appropriate options for all types of single-line closure statements used by the PHP programmers.
2) Class Properties
Class properties for the first time are being offered by any PHP version to this day. Without any difficulty and without breaking the code this new feature can be incorporated into older PHP versions as well.
3) Null Coalescing Operations
Null coalescing operations in new PHP 7.4 will help to do away with the code redundancy to a great extent.
4) Weak Reference Support
This feature will help developers to build structures similar to the cache. Weak Reference support in the new PHP version will allow retaining an object reference that can be destroyed as well.
Deprecations come as notices to developers for removal of certain functions in the future.
6) Performance Boost
One of the key reasons to opt for the new PHP version is definitely the promise of enhanced and improved performance. PHP 7.4 is built with that promise and so it introduced the performance-boosting feature of preloading to PHP core. This preloading to PHP core is done through an Opcache extension. This feature will make the response time faster as the need for loading scripts following every user request will be completely done away.
PHP 7.4 Alpha Release Features
Much ahead of the actual release of the full version, PHP 7.4 Alpha was released a couple of months before giving us the first picture of what the new PHP release is going to be all about. With this Alpha release, the first fleet of features was unveiled for the developers. Now, the PHP 7.4 Alpha version is available for download from PHP.net.
Let’s have a look at the key features of the PHP 7.4 Alpha version.
-> PHP 7.4 Alpha version unveiled the preloading feature which as we have seen can enhance the PHP websites and web apps to a great extent. By allowing preloading of the functions or classes that like caches will only remain active for a server session, the response time to any user request will be shortened by at least 30~50%, as initial tests confirmed.
-> Apart from the preloading feature, the new version will have PHP FFI extension to accommodate a Foreign Function Interface allowing programmers to incorporate native functions, variables or data structures of the C programming language. This will actually bring more power to PHP programming.
-> With the new PHP Alpha version, the Hash extension will be a permanent part of PHP that cannot be disabled further.
-> The new Alpha version comes with TLS 1.3 support within the support for PHP OpenSSL streams.
-> Apart from the above mentioned, the new PHP 7.4 boasts of a whole array of fixes and value additions.
PHP 7.4 Beta Release Features
PHP 7.4 Beta version has already been released in June this year. Being the first beta version of this new PHP update, it was expected to unveil few other enhancements over and above the Alpha version released earlier. Before the Beta 2 version is released, it is high time to take a note of the key features of PHP 7.4 first Beta release.
-> Arrow functions or Shorter functions for clean single-line statements and functions
-> Preloading feature to boost performance
-> Typed properties in classes
-> Enhanced type variance
-> The null coalescing operation to minimise redundancy of code
-> FFI for better PHP extension development
-> Use of underscores for formatting numeric values
-> Deprecated short open tags
-> A spread operator in arrays
PHP 7.4 is scheduled to be released in November this year. Before that, the features will be finalised with the release of another couple of beta releases in the coming months. The new version is already being looked after by PHP developers worldwide with a lot of expectations and promises.
SpaceX says it plans to begin offering broadband services to customers with its massive internet-from-space initiative, known as Starlink, as early as mid-2020, SpaceNews reports. The company needs to complete six to eight launches, with 60 satellites per ride, in order to get the service up and running, SpaceX president and COO Gwynne Shotwell told reporters during a media roundtable in Washington, DC.
Starlink is SpaceX’s proposed constellation of thousands of satellites, which are designed to orbit at low altitudes above the Earth and beam internet coverage to the surface below. SpaceX has so far secured licensing from the Federal Communications Commission to launch nearly 12,000 satellites into orbit. And just last week, the company submitted another request to an international regulator, the International Telecommunication Union (ITU), asking for radio frequencies to communicate with an additional 30,000 Starlink satellites. That means the company wants the ability to launch an estimated 42,000 satellites into orbit.
THE COMPANY NEEDS TO COMPLETE SIX TO EIGHT LAUNCHES
“As demand escalates for fast, reliable internet around the world, especially for those where connectivity is non-existent, too expensive or unreliable, SpaceX is taking steps to responsibly scale Starlink’s total network capacity and data density to meet the growth in users’ anticipated needs,” a company spokesperson said in a statement in reference to the new ITU filing.
So far, SpaceX has only launched 60 of its Starlink satellites on a single launch in May, and three of those satellites failed sometime after they made it to orbit. SpaceX also wound up taking two of the remaining satellites out of orbit, to prove that the company has the capability to remove the vehicles from space if necessary. However, the remaining satellites raised themselves to higher altitudes and seem to be working. SpaceX CEO Elon Musk tweeted on Monday night that he was going to send a tweet using the Starlink system. “Whoa, it worked!!” he wrote.
There’s still a lot of work to be done before people can start getting internet from Starlink. Apart from launching satellites, SpaceX still needs to finish developing its user terminal, a small device that customers will use to receive broadband signals from the satellites. The company also needs to figure out how it will roll out the service, according to SpaceNews. It’s possible the service will be offered directly to customers, while in some countries, customers will need to sign up for the service through a telecom service provider, according to Shotwell. A price point also needs to be determined.
“This is very different business for SpaceX,” Shotwell said, according to SpaceNews. “It’s leveraging space technology but it’s a consumer business.”