Skip to content

Instantly share code, notes, and snippets.

@rdp77
Last active August 11, 2022 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdp77/3478f7636f4c9081c448122f0a7b8fdc to your computer and use it in GitHub Desktop.
Save rdp77/3478f7636f4c9081c448122f0a7b8fdc to your computer and use it in GitHub Desktop.
Null Safety Handle
<?php
$a = null;
// Old Way
if(!$a){
echo "Hello World";
}
else{
echo $a;
}
// New Way
echo $a ?? "Hello World"; // New Text if variable is NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment