Intermediate PHP
Q50 / 100

What is PHP's union type declaration?

Correct! Well done.

Incorrect.

The correct answer is B) A type declaration accepting multiple types: function f(int|string $x)

B

Correct Answer

A type declaration accepting multiple types: function f(int|string $x)

Explanation

PHP 8 union types (int|string) allow parameters or returns to be one of the listed types. PHP 8.2 adds intersection types (Iterator&Countable).

Progress
50/100