PHP 8 New Features

PHP 8 New Features

We know that PHP is one of the mostly used programming language for Web Application development

In this blog, we are going to discuss about the new Features and Improvement in PHP 8

PHP 8 Overview

PHP 8 introduces new features like: functions, improvements, and deprecations to the language. The most awaited feature is the JIT compiler. To improve the performance of the application JIT was introduced, and also supports syntactical improvements.

Some of the new functions are introduced in php 8 are:

  • str_contains

To find out if one string contains another string. For this we can use strpos(). In place of strpos() we can str_contains

if (strpos(‘Foo Bar Baz’, ‘Foo’) !== false) {

    // FOUND

}

if (str_contains(‘Foo Bar Baz’, ‘Foo’)) {

          // FOUND

}

 

  • str_starts_with and str_ends_with
  • preg_last_error_msg
  • Get_debug_type

JIT Compiler – Just In Time Compiler

One of the most awaited features of PHP 8 is the JIT – Just In Time compiler. By using this compiler, we can improve the performance, Caching of compiled code and more…

PHP 8 Syntax Improvements:

The syntactical improvements in PHP 8 will help a lot to the PHP developers. Whether that is in eliminating common boilerplate between the promoted constructor arguments, or the improved error and exception handling, there’s a lot for developers to be excited about.

Union Types

“mixed” pseudo type

Class Constructor property promotion

::class ubiquity

Attributes

Match Expressions

Catch by type only

Throwing exceptions from expressions

For the purposes of this blog, we’ll be focusing on union types, match expressions, and attributes.

Share this post