Last active
June 28, 2022 13:19
-
-
Save Scemist/9fb56120be6c6bd4cff97ce401e727e5 to your computer and use it in GitHub Desktop.
Advanced PHP Operators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nome?->$email?->$cpf // Nullsafe Operator | |
$valor = true ? 'um' : 'dois'; // Ternary Operator | |
$valor = $test ?? 'é null'; // Null Coalescing | |
$valor = $test ?: 0 ?: null ?: 2 ?: 'asd'; // Elvis Operator | |
# Elvis operator returns ERROR if variable is not defined, in this case, use Null Coalescing instead. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment