It works fine and doesn't cause problem
echo $formErrorBag[ 'email' ] ?? null
But is it an accepted practice? Never saw an example of this used with null.
The null coalesce operator checks values with isset(), so this:
echo $formErrorBag['email'] ?? null;
Equals:
if(isset($formErrorBag['email'])){
echo $formErrorBag['email'];
} else {
echo null;
}
I really don't see the point in that as you are still executing a function doing literally nothing. If you are doing this to avoid raising an E_NOTICE you can simply turn it off with error_reporting() as doing your method kinda breaks the entire point of that.
It's there to warn you about a possible bug in your code, not finding techniques to suppress it.
error_reporting(error_reporting() ^ E_NOTICE); // turn notices off keep remaining flags intact.
echo $array['doesnotexist'];
echo $array['etc'];
error_reporting(error_reporting() | E_NOTICE); // turn it back on.
$formErrorBag['email']is null this will already return null, you are just adding extra code that will make your application slower.