PHP 8.3 was released with a bundle of exciting new features, syntax refinements, and performance improvements that elevate the language further.
1. Typed Class Constants
In PHP 8.3, you can declare explicit types for class, interface, and trait constants. This prevents child classes from accidentally changing constant types:
class Application {
public const string VERSION = '1.2.0';
public const int MAX_LIMIT = 100;
}
2. The new json_validate() Function
Previously, validating if a string is a valid JSON required parsing it with json_decode(), which consumes memory. The new helper function checks syntax without decoding the content:
if (json_validate($jsonString)) {
// String is valid JSON
}
3. Dynamic Class Constant Fetch
You can now fetch constants dynamically using a variable name without having to use the constant() helper function:
class Status {
public const PENDING = 'pending';
}
$name = 'PENDING';
echo Status::{$name}; // Output: pending
Conclusion
Upgrading to PHP 8.3 brings better type safety, memory-efficient JSON validations, and cleaner syntax, helping developer teams build secure, high-performance web backends.