In earlier versions of PHP, if you created a new object instance and immediately wanted to chain a method or access a property, you had to wrap the instantiation in extra parentheses, such as (new User())->getName(). PHP 8.4 simplifies this syntax, allowing direct member access immediately after instantiation without any surrounding parentheses.

PHP 8.4 Example

PHP
class App
{
    public function version(): string
    {
        return 'v8.4.0';
    }
}

// PHP 8.4 allows direct access without parenthetical wrapping
$version = new App()->version();
echo $version; // Outputs: v8.4.0

The articles and images featured on this platform were generated with the assistance of AI tools.