Programming Languages
PHP
Objective
Sep 23, 2025
What is the correct way to implement a PHP 8+ union type for a parameter that accepts string or int?
Detailed Explanation
Explanation: PHP 8.0 introduced union types using the pipe (|) operator. This allows a parameter to accept multiple types. Union types provide better type safety while maintaining flexibility.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts