0
0

More than 1 year has passed since last update.

【PHP】演算子の小ネタ

Last updated at Posted at 2022-02-10

コード

<?php
// 定義されているかどうか?
//Null合体演算子
$a = 'aaaaaa';

echo $a ?? 'good bye';
echo PHP_EOL;
echo $c ?? 'レス急';


echo PHP_EOL;

// 値が入っているかどうか?
//エルビス演算子
$b = '';

echo $b ?: 'good bye';
echo PHP_EOL;
$sobi_data = "不倫";
$all = "{NAME}弁護士";
echo str_replace('{NAME}', $sobi_data,$all);

結果

aaaaaa
レス急
good bye
不倫弁護士

0
0
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
0
0