Software and Hardware Programming Software Objective
Sep 23, 2025

What is the purpose of the nullsafe operator (?->) in PHP 8?

Choose the correct answer:
A) To check if a variable is null
B) To safely call methods on potentially null objects
C) To assign null values
D) To compare with null
Detailed Explanation

Explanation: The nullsafe operator (?->) introduced in PHP 8.0 allows you to safely call methods or access properties on objects that might be null. If the object is null, the entire chain returns null instead of throwing an error.

Discussion (0)

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

Share Your Thoughts
Feedback