Programming Languages PHP Objective
Sep 23, 2025

What is the correct way to declare a PHP 8+ intersection type?

Choose the correct answer:
A) function test(A|B $param)
B) function test(A&B $param)
C) function test(A,B $param)
D) function test(A+B $param)
Detailed Explanation

Explanation: PHP 8.1 introduced intersection types using the ampersand (&) operator. This means the parameter must satisfy all specified types simultaneously, useful for objects implementing multiple interfaces.

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback