I’m currently following through the PHP Novice to Ninja book, and adapting it for a blog website. I have potential problem if a user account is deleted and I’m wondering how I might do the equivalent of a null coalescecing operator on the following name property of a comment object:
The null coalescing operator will not work on the output of htmlspecialchars(), because htmlspecialchars() always returns a string - in case of null input it will output an empty string. You have to use it on the value which can be null. Supposing $comment->getAuthor()->email can be null you can do this: