Start your project
Start tu=
Home · Sin categorizar · PHP 8.4 is here! Discover what’s new

PHP 8.4 is here! Discover what’s new

Scroll to discover

PHP continues to evolve to make our work easier and more efficient. The arrival of PHP 8.4 brings improvements that seek to optimize web development, both in performance and functionality. If you work with this language on a daily basis, get ready for these new features that will make you love PHP even more!

📌 Property Hooks: more magic and less code

What are Property Hooks?

Property Hooks are one of the star features of PHP 8.4. They allow us to intercept access or modification of properties in classes, something that previously required implementing tedious methods get and set. Now, you can define custom behaviors with much less effort.

How does it work?

Imagine you have a class with two properties, nombre y apellido. Con Property Hooks, podrías crear una propiedad virtual llamada nombreCompleto que se actualiza automáticamente. Esto mejora la legibilidad y reduce líneas de código.


class Persona {
    public string $nombre;
    public string $apellido;

    public function __get(string $property): string {
        if ($property === 'nombreCompleto') {
            return $this->nombre . ' ' . $this->apellido;
        }
    }
}

Isn’t it great? Plus, it helps keep the code cleaner and more organized.

👀 Asymmetric Visibility: better control your data

What is asymmetric visibility?

Another important new feature is the possibility of assigning different levels of visibility for reading and writing properties. Now you can, for example, allow a property to be public for reading but private or write-protected.

Why is it useful?

This allows you to protect your data from unwanted modifications while still providing read access. Ideal for maintaining the integrity of your business logic.

🔗 Easier method chaining

Goodbye to unnecessary parentheses

PHP 8.4 introduces an improvement that seems small, but makes a big difference in terms of code readability: method chaining on newly instantiated objects now does not require extra parentheses. This change reduces visual noise, making it clearer and easier to read.


// Antes
$nuevaInstancia = (new Clase())->metodo();

// Ahora
$nuevaInstancia = new Clase()->metodo();

Little things like this remind us that PHP is constantly evolving to improve our experience as developers.

🛠️ New functions for working with arrays

Functions such as array_find() and array_any()

PHP 8.4 expands its arsenal of tools for working with arrays. These new functions make searching for elements and evaluating conditions more straightforward, saving lines of code.

A practical example

With array_find()If you want to find the first element of an array that meets a specific condition, such as finding a product in stock, you can search for the first element of an array that meets a specific condition, such as finding a product in stock:


$producto = array_find($productos, fn($p) => $p->stock > 0);

Clearer, faster and more efficient.

🌐 DOM with HTML5 support

What changes with HTML5?

The DOM extension receives an important update: it now has full support for HTML5. This means you can manipulate modern HTML documents more easily, especially if you work on complex projects or dynamic content generators.

New classes

Classes are added Dom\HTMLDocument y Dom\XMLDocumentThe new system is designed to be more efficient and compatible with today’s standards.

💾 Specific subclasses for PDO

More control over databases

If you use PDO to connect your applications to databases, PHP 8.4 comes with specific subclasses such as Pdo\Mysql, Pdo\Pgsql y Pdo\Sqlite. Estas subclases hacen que trabajar con características específicas de cada base de datos sea mucho más claro y directo.

➗ BCMath enhancements

More intuitive mathematical operations

The BCMath extension now includes the class BcMath\NumberDo you need to add large numbers or perform complex calculations? Now you can do it with standard operators.

✂️ New multibyte functions for strings

Perfect for multilingual projects

Working with multibyte strings (useful for languages with special characters) is much more convenient thanks to functions such as mb_trim(), mb_ucfirst() and more. If your application supports multiple languages, you will notice the difference.

🛑 Deprecations: goodbye to dynamic properties

In this version, PHP takes another step towards code robustness. Dynamic properties are officially deprecated, which means that you will have to explicitly declare all properties in your classes. This may seem a bit annoying at first, but it improves the security and maintainability of your projects in the long run.

🛠️ What to keep in mind if you use WordPress or Laravel?

When working with PHP, one of the key decisions is to choose the right tool for each project. Both WordPress and Laravel have advantages and limitations, depending on what you need to build. Here is a quick guide to help you decide.

🌐 WordPress

WordPress is ideal for websites that need to be easily managed by non-technical users. Its ecosystem of plugins and themes makes it the perfect choice for blogs, online stores and corporate sites.

  • Quick to implement.
  • SEO friendly thanks to plugins like Yoast.
  • Great community and support.
  • Less control over advanced customizations.

⚙️ Laravel

Laravel is a framework for developers looking to create advanced, custom web applications. It offers flexibility, scalability and full control over business logic.

  • Perfect for complex projects or SaaS applications.
  • Highly customizable.
  • Higher learning curve.
  • Requires more development time.

🚀 Let’s try PHP 8.4!

PHP 8.4 not only modernizes the language, but also optimizes the way we develop. With these new features, writing clean, efficient and secure code will be easier than ever. Are you ready to upgrade your projects? PHP 8.4 is here to stay!

Share on

Featured Posts

SCROLL TO EXPLORE·SCROLL TO EXPLORE·
Start your project

Name(Required)
This field is for validation purposes and should be left unchanged.