問題はこちら
解答
answer.php
<?php
//文字列を代入
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
//$a, $bの比較
if ($a === $b) {
echo 'OK';
}else {
echo 'NG';
}
?>
Point
今回は特に特筆すべき点はありませんが、文字列という指定がありましたので、==ではなく===を利用しています。PHPにおいて、==は型の比較がなく、===では型の一致も確認されます。比較演算子に関する詳しい内容は以下マニュアルからどうぞ。
参照
https://paiza.jp/works/mondai/d_rank_skillcheck_sample/diff_str
PHPの比較演算子について
https://www.php.net/manual/ja/language.operators.comparison.php