PHP 8.4 — Features Worth Knowing
A practical guide to pHP 8.4 — Features Worth Knowing — tips, best practices, and real-world examples.
# PHP 8.4 — Features Worth Knowing
PHP 8.4 brings exciting new features. Here are the highlights.
## Property Hooks
```php
class User
{
private string $name;
public string $displayName {
get => $this->name;
set(string $value) {
$this->name = trim($value);
}
}
}
```
## New Array Find Functions
```php
$first = array_find($users, fn($u) => $u->active);
$all = array_find_all($users, fn($u) => $u->role === 'admin');
```
## Asymmetric Visibility
```php
class BankAccount
{
public private(set) float $balance = 0.0;
}
```
`public` read, `private` write!
## HTML5 Support
Better DOM handling with HTML5 parsing.
## Deprecated Features
- Implicit nullable parameters
- Calling static methods on traits
## Conclusion
PHP 8.4 modernizes PHP with cleaner syntax and better capabilities.
PHP 8.4 brings exciting new features. Here are the highlights.
## Property Hooks
```php
class User
{
private string $name;
public string $displayName {
get => $this->name;
set(string $value) {
$this->name = trim($value);
}
}
}
```
## New Array Find Functions
```php
$first = array_find($users, fn($u) => $u->active);
$all = array_find_all($users, fn($u) => $u->role === 'admin');
```
## Asymmetric Visibility
```php
class BankAccount
{
public private(set) float $balance = 0.0;
}
```
`public` read, `private` write!
## HTML5 Support
Better DOM handling with HTML5 parsing.
## Deprecated Features
- Implicit nullable parameters
- Calling static methods on traits
## Conclusion
PHP 8.4 modernizes PHP with cleaner syntax and better capabilities.
PHP