How to use Union Types in PHP

Published On2020-07-24

PHP 8 Union Types

One of the most exciting features in PHP 8.0 is Union Types. Union Types allow you to declare a type constraint as a union of two or more types.

Recent Articles on PHP.Watch

All ArticlesFeed
PHP 8.0 Reached Feature-Freeze

PHP 8.0 Reached Feature-Freeze

PHP 8.0 reached its feature-freeze, which means we know which major features make it to PHP 8.0.
PHP 8: Override internal functions with `disable_functions` INI directive

PHP 8: Override internal functions with `disable_functions` INI directive

Creative ways to polyfill/mock PHP internal functions with `disabled_functions` feature
PHP 8 Alpha 1 released

PHP 8 Alpha 1 released

PHP 8 Alpha version 1 is released on the same month PHP turned 25!
Subscribe to PHP.Watch newsletter for monthly updates

You will receive an email on last Saturday of every month and on major PHP releases with new articles related to PHP, upcoming changes, new features and what's changing in the language. No marketing emails, no selling of your contacts, no click-tracking, and one-click instant unsubscribe from any email you receive.