CONTACT: ICQ 22233 and PM

Conditional assignment: Null coalescing (??)

Messages
283
Reaction score
0
Code:
<!DOCTYPE html>
<html>
<body>

<?php
   // variable $user is the value of $_GET['user']
   // and 'anonymous' if it does not exist
   echo $user = $_GET["user"] ?? "anonymous";
   echo("<br>");
 
   // variable $color is "red" if $color does not exist or is null
   echo $color = $color ?? "red";
?> 

</body>
</html>
 
Top