LoginSignup
2
1

More than 3 years have passed since last update.

NULL合体演算子

Posted at

今日、便利だなと思ったphpの記法をメモ

NULL合体演算子

基本構文

条件式または$変数 ?? 真の式;

条件式または$変数がnullの場合真の式を返し、条件式または$変数がnullでは無い場合、条件式または$変数を返します。
(例)

$name = null;
$username = $name ?? '名無し';
echo $username; // 名無し

(参考
https://www.sejuku.net/blog/23070
https://www.php.net/manual/ja/migration70.new-features.php

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1