揮発性のメモ2

http://d.hatena.ne.jp/iww/

PHP8.1で "Deprecated: ucfirst(): Passing null to parameter #1 ($string) of type string is deprecated in"

PHP8.1で既存のプログラムを動かすと、Deprecated(非推奨)のエラーがやたら出る。

<?php
$a = ucfirst(null);
var_dump($a);
Deprecated: ucfirst(): Passing null to parameter #1 ($string) of type string is deprecated in /home/user/scripts/code.php on line 2
string(0) ""

今までは nullable だったのに、なんか急にダメ扱いにしたのが原因。
www.php.net

また、PHP8.0から error_reporting が E_ALL になって、なんでもかんでもエラーが出力されるようになった。
www.php.net

そのため、PHP5.x 時代の化石を動かすとエラーがドンドコ出る。

暫定的には エラー出力を抑制するのが一番楽

; /etc/php.d/99-hoge.ini

[PHP]
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED