HHeLiBeXの日記 正道編

日々の記憶の記録とメモ‥

型宣言~string~

型宣言のstring編。どこまで許容されるのか検証。

Main.php

<?php

function to_string($val):string {
    print "=== val=" . var_export($val, true) . " ===" . PHP_EOL;
    try {
        return $val;
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
        return '';
    }
}

class Hoge {
    private int $val;
    public function __construct($val) {
        $this->val = $val;
    }
}
class MyInteger {
    private int $val;
    public function __construct($val) {
        $this->val = $val;
    }
    public function __toString():string {
        return $this->val;
    }
}

var_dump(to_string(0));
var_dump(to_string(00));
var_dump(to_string(123));
var_dump(to_string(0123));
var_dump(to_string(0x123));
var_dump(to_string(0.1));
var_dump(to_string(1.23));
var_dump(to_string(false));
var_dump(to_string(true));
var_dump(to_string("0"));
var_dump(to_string("00"));
var_dump(to_string("123"));
var_dump(to_string("0123"));
var_dump(to_string("0x123"));
var_dump(to_string("hello"));
var_dump(to_string(null));
var_dump(to_string(new Hoge("123456789")));
var_dump(to_string(new MyInteger("123456789")));

実行結果。

$ php81 Main.php
=== val=0 ===
string(1) "0"
=== val=0 ===
string(1) "0"
=== val=123 ===
string(3) "123"
=== val=83 ===
string(2) "83"
=== val=291 ===
string(3) "291"
=== val=0.1 ===
string(3) "0.1"
=== val=1.23 ===
string(4) "1.23"
=== val=false ===
string(0) ""
=== val=true ===
string(1) "1"
=== val='0' ===
string(1) "0"
=== val='00' ===
string(2) "00"
=== val='123' ===
string(3) "123"
=== val='0123' ===
string(4) "0123"
=== val='0x123' ===
string(5) "0x123"
=== val='hello' ===
string(5) "hello"
=== val=NULL ===
to_string(): Return value must be of type string, null returned
#0 /home/hhelibex/blog/2022-0617-01/Main.php(45): to_string()
#1 {main}
string(0) ""
=== val=Hoge::__set_state(array(
   'val' => 123456789,
)) ===
to_string(): Return value must be of type string, Hoge returned
#0 /home/hhelibex/blog/2022-0617-01/Main.php(46): to_string()
#1 {main}
string(0) ""
=== val=MyInteger::__set_state(array(
   'val' => 123456789,
)) ===
string(9) "123456789"
$ 

予想通り、__toString() を実装しておくと、objectをstringに変換してくれる。

しかし、「false」「true」が「""」「"1"」に変換されるのには未だに慣れない。

型宣言~int~

型宣言のint編。どこまで許容されるのか検証。

Main.php

<?php

function to_int($val):int {
    print "=== val=" . var_export($val, true) . " ===" . PHP_EOL;
    try {
        return $val;
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
        return -1;
    }
}

class Hoge {
    private int $val;
    public function __construct($val) {
        $this->val = $val;
    }
}
class MyInteger {
    private int $val;
    public function __construct($val) {
        $this->val = $val;
    }
    public function __toString():string {
        return $this->val;
    }
}

var_dump(to_int(0));
var_dump(to_int(00));
var_dump(to_int(123));
var_dump(to_int(0123));
var_dump(to_int(0x123));
var_dump(to_int(0.1));
var_dump(to_int(1.23));
var_dump(to_int(false));
var_dump(to_int(true));
var_dump(to_int("0"));
var_dump(to_int("00"));
var_dump(to_int("123"));
var_dump(to_int("0123"));
var_dump(to_int("0x123"));
var_dump(to_int("hello"));
var_dump(to_int(null));
var_dump(to_int(new Hoge("123456789")));
var_dump(to_int(new MyInteger("123456789")));

実行結果。

$ php81 Main.php
=== val=0 ===
int(0)
=== val=0 ===
int(0)
=== val=123 ===
int(123)
=== val=83 ===
int(83)
=== val=291 ===
int(291)
=== val=0.1 ===
int(0)
=== val=1.23 ===
int(1)
=== val=false ===
int(0)
=== val=true ===
int(1)
=== val='0' ===
int(0)
=== val='00' ===
int(0)
=== val='123' ===
int(123)
=== val='0123' ===
int(123)
=== val='0x123' ===
to_int(): Return value must be of type int, string returned
#0 /home/hhelibex/blog/2022-0616-01/Main.php(43): to_int()
#1 {main}
int(-1)
=== val='hello' ===
to_int(): Return value must be of type int, string returned
#0 /home/hhelibex/blog/2022-0616-01/Main.php(44): to_int()
#1 {main}
int(-1)
=== val=NULL ===
to_int(): Return value must be of type int, null returned
#0 /home/hhelibex/blog/2022-0616-01/Main.php(45): to_int()
#1 {main}
int(-1)
=== val=Hoge::__set_state(array(
   'val' => 123456789,
)) ===
to_int(): Return value must be of type int, Hoge returned
#0 /home/hhelibex/blog/2022-0616-01/Main.php(46): to_int()
#1 {main}
int(-1)
=== val=MyInteger::__set_state(array(
   'val' => 123456789,
)) ===
to_int(): Return value must be of type int, MyInteger returned
#0 /home/hhelibex/blog/2022-0616-01/Main.php(47): to_int()
#1 {main}
int(-1)
$ 

最後のMyIntegerクラスは、ワンチャン __toString() が呼び出されて変換されたりしないかなと思ったりしたけどそんなわけはなかった。

ここで注意すべきなのは、あくまでも「:int」であり「:integer」とは書けないということ。 マニュアルに以下の記述がある。

警告 上記のスカラー型のエイリアスはサポートされていません。 つまり、これらはクラスやインターフェイスの名前として扱われているということです。 たとえば、型の宣言に boolean を使った場合、 値が boolean クラスまたはインターフェイスインスタンスであることが要求されます。 bool 型ではありません。

もし「:integer」と書いた場合、実行結果は以下のようになる。

PHP Warning:  "integer" will be interpreted as a class name. Did you mean "int"? Write "\integer" to suppress this warning in /home/hhelibex/blog/2022-0616-01/Main.php on line 3
=== val=0 ===
to_int(): Return value must be of type integer, int returned
#0 /home/hhelibex/blog/2022-0616-01/Main.php(30): to_int()
#1 {main}
PHP Fatal error:  Uncaught TypeError: to_int(): Return value must be of type integer, int returned in /home/hhelibex/blog/2022-0616-01/Main.php:10
Stack trace:
#0 /home/hhelibex/blog/2022-0616-01/Main.php(30): to_int()
#1 {main}
  thrown in /home/hhelibex/blog/2022-0616-01/Main.php on line 10

type hintingの改善(Type declarations/型宣言)

だいぶ昔に以下の記事を書いた。

hhelibex.hatenablog.jp

それからだいぶ時が経ったものの、PHP 5.xの世界でずっと生きてきたので気付かなかった。

これによると、

英語

Type declarations can be added to function arguments, return values, and, as of PHP 7.4.0, class properties. They ensure that the value is of the specified type at call time, otherwise a TypeError is thrown.

日本語

関数のパラメータや戻り値、 クラスのプロパティ (PHP 7.4.0 以降) に対して型を宣言することができます。 これによって、その値が特定の型であることを保証できます。 その型でない場合は、TypeError がスローされます。

というわけでさわりだけ試してみる。

パラメータ

Main1.php

<?php

function hoge(int $val) {
    var_dump($val);
}

class Hoge {
    public function foo(int $val) {
        var_dump(__FUNCTION__, $val);
    }
    public function bar(string $val) {
        var_dump(__FUNCTION__, $val);
    }
    public function piyo(Hoge $val) {
        var_dump(__FUNCTION__, $val);
    }
    public function __toString() {
        return var_export($this, true);
    }
}

print "===function hoge(int)===" . PHP_EOL;
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        hoge($val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}

print "===method foo(int)===" . PHP_EOL;
$hoge = new Hoge();
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        $hoge->foo($val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}
print "===method bar(string)===" . PHP_EOL;
$hoge = new Hoge();
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        $hoge->bar($val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}
print "===method piyo(Hoge)===" . PHP_EOL;
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        $hoge->piyo($val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}

実行結果。長くなるので、代表してPHP 8.1に出てもらう。

$ php81 Main1.php
===function hoge(int)===
===    1    ===
int(1)
===    '2'    ===
int(2)
===    true    ===
int(1)
===    '00'    ===
int(0)
===    'hello'    ===
hoge(): Argument #1 ($val) must be of type int, string given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 26
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(26): hoge()
#1 {main}
===    Hoge::__set_state(array(
))    ===
hoge(): Argument #1 ($val) must be of type int, Hoge given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 26
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(26): hoge()
#1 {main}
===method foo(int)===
===    1    ===
string(3) "foo"
int(1)
===    '2'    ===
string(3) "foo"
int(2)
===    true    ===
string(3) "foo"
int(1)
===    '00'    ===
string(3) "foo"
int(0)
===    'hello'    ===
Hoge::foo(): Argument #1 ($val) must be of type int, string given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 38
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(38): Hoge->foo()
#1 {main}
===    Hoge::__set_state(array(
))    ===
Hoge::foo(): Argument #1 ($val) must be of type int, Hoge given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 38
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(38): Hoge->foo()
#1 {main}
===method bar(string)===
===    1    ===
string(3) "bar"
string(1) "1"
===    '2'    ===
string(3) "bar"
string(1) "2"
===    true    ===
string(3) "bar"
string(1) "1"
===    '00'    ===
string(3) "bar"
string(2) "00"
===    'hello'    ===
string(3) "bar"
string(5) "hello"
===    Hoge::__set_state(array(
))    ===
string(3) "bar"
string(27) "Hoge::__set_state(array(
))"
===method piyo(Hoge)===
===    1    ===
Hoge::piyo(): Argument #1 ($val) must be of type Hoge, int given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 59
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(59): Hoge->piyo()
#1 {main}
===    '2'    ===
Hoge::piyo(): Argument #1 ($val) must be of type Hoge, string given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 59
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(59): Hoge->piyo()
#1 {main}
===    true    ===
Hoge::piyo(): Argument #1 ($val) must be of type Hoge, bool given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 59
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(59): Hoge->piyo()
#1 {main}
===    '00'    ===
Hoge::piyo(): Argument #1 ($val) must be of type Hoge, string given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 59
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(59): Hoge->piyo()
#1 {main}
===    'hello'    ===
Hoge::piyo(): Argument #1 ($val) must be of type Hoge, string given, called in /home/hhelibex/blog/2022-0615-01/Main1.php on line 59
#0 /home/hhelibex/blog/2022-0615-01/Main1.php(59): Hoge->piyo()
#1 {main}
===    Hoge::__set_state(array(
))    ===
string(4) "piyo"
object(Hoge)#4 (0) {
}
$

ある程度なら(string(1) "2"⇒int(2)/bool(true)⇒int(1)/string(2) "00"⇒int(0)/ ⇒string() "*")キャストして扱ってくれるらしい。 オブジェクトも、__toString()メソッドを実装するとstringにキャストして渡される。

戻り値

Main2.php

<?php

function hoge($val):int {
    return $val;
}

class Hoge {
    public function foo($val):int {
        return $val;
    }
    public function bar($val):string {
        return $val;
    }
    public function piyo($val):Hoge {
        return $val;
    }
    public function __toString() {
        return var_export($this, true);
    }
}

print "===function hoge():int===" . PHP_EOL;
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        var_dump($val, hoge($val));
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}

print "===method foo():int===" . PHP_EOL;
$hoge = new Hoge();
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        var_dump($val, $hoge->foo($val));
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}
print "===method bar():string===" . PHP_EOL;
$hoge = new Hoge();
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        var_dump($val, $hoge->bar($val));
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}
print "===method piyo():Hoge===" . PHP_EOL;
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        var_dump($val, $hoge->piyo($val));
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}

実行結果。

$ php81 Main2.php
===function hoge():int===
===    1    ===
int(1)
int(1)
===    '2'    ===
string(1) "2"
int(2)
===    true    ===
bool(true)
int(1)
===    '00'    ===
string(2) "00"
int(0)
===    'hello'    ===
hoge(): Return value must be of type int, string returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(26): hoge()
#1 {main}
===    Hoge::__set_state(array(
))    ===
hoge(): Return value must be of type int, Hoge returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(26): hoge()
#1 {main}
===method foo():int===
===    1    ===
int(1)
int(1)
===    '2'    ===
string(1) "2"
int(2)
===    true    ===
bool(true)
int(1)
===    '00'    ===
string(2) "00"
int(0)
===    'hello'    ===
Hoge::foo(): Return value must be of type int, string returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(38): Hoge->foo()
#1 {main}
===    Hoge::__set_state(array(
))    ===
Hoge::foo(): Return value must be of type int, Hoge returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(38): Hoge->foo()
#1 {main}
===method bar():string===
===    1    ===
int(1)
string(1) "1"
===    '2'    ===
string(1) "2"
string(1) "2"
===    true    ===
bool(true)
string(1) "1"
===    '00'    ===
string(2) "00"
string(2) "00"
===    'hello'    ===
string(5) "hello"
string(5) "hello"
===    Hoge::__set_state(array(
))    ===
object(Hoge)#2 (0) {
}
string(27) "Hoge::__set_state(array(
))"
===method piyo():Hoge===
===    1    ===
Hoge::piyo(): Return value must be of type Hoge, int returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(59): Hoge->piyo()
#1 {main}
===    '2'    ===
Hoge::piyo(): Return value must be of type Hoge, string returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(59): Hoge->piyo()
#1 {main}
===    true    ===
Hoge::piyo(): Return value must be of type Hoge, bool returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(59): Hoge->piyo()
#1 {main}
===    '00'    ===
Hoge::piyo(): Return value must be of type Hoge, string returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(59): Hoge->piyo()
#1 {main}
===    'hello'    ===
Hoge::piyo(): Return value must be of type Hoge, string returned
#0 /home/hhelibex/blog/2022-0615-01/Main2.php(59): Hoge->piyo()
#1 {main}
===    Hoge::__set_state(array(
))    ===
object(Hoge)#4 (0) {
}
object(Hoge)#4 (0) {
}
$ 

クラスのプロパティ(PHP 7.4.0以降)

Main3.php

<?php

class Hoge {
    public int $int_val;
    public string $str_val;
    public Hoge $hoge_val;
    public function __toString() {
        return var_export($this, true);
    }
}

$hoge = new Hoge();
foreach (array(1, "2", true, "00", "hello", new Hoge()) as $val) {
    print "===    " . var_export($val, true) . "    ===" . PHP_EOL;
    try {
        $hoge->int_val = $val;
        var_dump($hoge->int_val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
    try {
        $hoge->str_val = $val;
        var_dump($hoge->str_val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
    try {
        $hoge->hoge_val = $val;
        var_dump($hoge->hoge_val);
    } catch (TypeError $e) {
        print $e->getMessage() . PHP_EOL;
        print $e->getTraceAsString() . PHP_EOL;
    }
}

実行結果。

$ php81 Main3.php
===    1    ===
int(1)
string(1) "1"
Cannot assign int to property Hoge::$hoge_val of type Hoge
#0 {main}
===    '2'    ===
int(2)
string(1) "2"
Cannot assign string to property Hoge::$hoge_val of type Hoge
#0 {main}
===    true    ===
int(1)
string(1) "1"
Cannot assign bool to property Hoge::$hoge_val of type Hoge
#0 {main}
===    '00'    ===
int(0)
string(2) "00"
Cannot assign string to property Hoge::$hoge_val of type Hoge
#0 {main}
===    'hello'    ===
Cannot assign string to property Hoge::$int_val of type int
#0 {main}
string(5) "hello"
Cannot assign string to property Hoge::$hoge_val of type Hoge
#0 {main}
===    Hoge::__set_state(array(
))    ===
Cannot assign Hoge to property Hoge::$int_val of type int
#0 {main}
string(27) "Hoge::__set_state(array(
))"
object(Hoge)#2 (0) {
  ["int_val"]=>
  uninitialized(int)
  ["str_val"]=>
  uninitialized(string)
  ["hoge_val"]=>
  uninitialized(Hoge)
}
$ 

所感

パラメータの型宣言(type hinting)がもう少し早くプリミティブ型に対応していてくれれば、あんな苦労(何)をせずに済んだのになぁ、とは思う。

いずれにしても、これで型安全なコーディングがしやすくなることは確か。

もう少し検証が必要な気がするので、それはまた後日。

オブジェクトの存在しないプロパティを参照したときの挙動

もしかしてオブジェクトの場合もか?ということで試したメモ。

Main.php

<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);

class A {
    public $a = null;
}
$a = new A();
var_dump($a->a);
var_dump($a->b);

実行結果。

$ for php in php56 php70 php71 php72 php73 php74 php80 php81 php82 ; do echo "===${php}===" ; ${php} Main.php ; done
===php56===
NULL
PHP Notice:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Notice: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php70===
NULL
PHP Notice:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Notice: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php71===
NULL
PHP Notice:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Notice: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php72===
NULL
PHP Notice:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Notice: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php73===
NULL
PHP Notice:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Notice: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php74===
NULL
PHP Notice:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Notice: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php80===
NULL
PHP Warning:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Warning: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php81===
NULL
PHP Warning:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Warning: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
===php82===
NULL
PHP Warning:  Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11

Warning: Undefined property: A::$b in /home/hhelibex/blog/2022-0614-01/Main.php on line 11
NULL
$ 

配列の場合と同様に、PHP 8.0から「Warning」に変わっている。

参考

hhelibex.hatenablog.jp hhelibex.hatenablog.jp

配列の存在しないキーを参照したときの挙動

PHP 5.4.16で動いているシステムをPHP 8.1.6に移行しようとしてハマったのだが、Smarty 2.xでは、error_reportingの値を書き換えてE_NOTICEを勝手に抑制していたことが発覚した今日この頃。

PHP 8.1.6にしてみるとどうにもWarningが止まらない。Smartyの未定義変数を参照したときは暗黙のうちに無視されるものだと思っていたので、しばらく原因が分からず参っていた。

よくよくテストスクリプトの実行結果を見たら、配列の未定義キーを参照したときのエラーメッセージが、PHP 5.4.16では「Notice」だったのが、PHP 8.1.6では「Warning」に格上げされていた。

というわけで、いつ変わったのかの確認。

Main.php

<?php

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);

$a = array("a" => "AAA");
var_dump($a["b"]);

実行結果。

$ for php in php56 php70 php71 php72 php73 php74 php80 php81 php82 ; do echo "===${php}===" ; ${php} Main.php ; done
===php56===
PHP Notice:  Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php70===
PHP Notice:  Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php71===
PHP Notice:  Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php72===
PHP Notice:  Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php73===
PHP Notice:  Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php74===
PHP Notice:  Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php80===
PHP Warning:  Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php81===
PHP Warning:  Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
===php82===
PHP Warning:  Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7

Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7
NULL
$ 

PHP 8.0から変わったようだ。

ちなみに、Smarty 3.x、4.xではどうなっているかというと、error_reportingの設定は完全に外側に丸投げ。つまり、単に{$hoge}と書けていたものを{if isset($hoge)}{$hoge}{/if}とするか、コントローラ側で変数 $hoge を確実に定義してやる必要が出てくる。

ついでなので、phpallもしておく。

php-4.2.0:  Notice: Undefined index: b in Main.php on line 7 NULL
php-4.2.1:  Notice: Undefined index: b in Main.php on line 7 NULL
php-4.2.2:  Notice: Undefined index: b in Main.php on line 7 NULL
php-4.2.3:  Notice: Undefined index: b in Main.php on line 7 NULL
php-4.3.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.3.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-4.4.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.0.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.0.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.0.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.0.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.0.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.0.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.1.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.2.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.3.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.34:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.35:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.36:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.37:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.38:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.39:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.40:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.41:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.42:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.43:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.44:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.4.45:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.34:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.35:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.36:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.37:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.5.38:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.34:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.35:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.36:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.37:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.38:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.39:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-5.6.40:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.0.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.1.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.2.34:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.17:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.31:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.32:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.3.33:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.0:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.1:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.2:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.3:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.4:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.5:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.6:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.7:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.8:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.9:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.10:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.11:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.12:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.13:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.14:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.15:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.16:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.18:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.19:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.20:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.21:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.22:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.23:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.24:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.25:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.26:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.27:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.28:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.29:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-7.4.30:  Notice: Undefined index: b in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.0:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.1:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.2:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.3:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.5:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.6:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.7:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.8:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.9:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.10:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.11:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.12:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.13:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.14:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.15:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.16:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.17:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.18:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.19:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.0.20:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.0:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.1:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.2:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.3:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.4:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.5:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.6:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL
php-8.1.7:  Warning: Undefined array key "b" in /home/hhelibex/blog/2022-0613-01/Main.php on line 7 NULL

PHP 8.0.0以降、「Notice」が「Warning」に変わり、メッセージも「Undefined index」から「Undefined array key~」に変わっている。

オブジェクトに対するarray_key_exists関数呼び出しの代替策について

array_key_exists関数の第二パラメータにオブジェクトを渡すとエラーになるようになってから久しいが、PHP 5.4.16で動くシステムを最低でもPHP 7.3以降に上げなければならなくなったためにぶつかった壁の調査。

以下のようなコードをPHP 5.6.40/7.4.29/8.1.6で実行してみる。

<?php

printf("%s\n", PHP_VERSION);

ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);

class A {
}

$obj = new A();
$ary = array();

$k = 'noExistence';
printf("%-12s: %d %d\n",
    $k,
    array_key_exists($k, $ary),
    array_key_exists($k, $obj));
$ php56 Main.php
5.6.40
noExistence : 0 0
$ 
$ php74 Main.php
7.4.29
PHP Deprecated:  array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /home/hhelibex/blog/2022-0518-01/Main.php on line 18

Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in /home/hhelibex/blog/2022-0518-01/Main.php on line 18
noExistence : 0 0
$ 
$ php81 Main.php
8.1.6
PHP Fatal error:  Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, A given in /home/hhelibex/blog/2022-0518-01/Main.php:18
Stack trace:
#0 {main}
  thrown in /home/hhelibex/blog/2022-0518-01/Main.php on line 18

Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, A given in /home/hhelibex/blog/2022-0518-01/Main.php:18
Stack trace:
#0 {main}
  thrown in /home/hhelibex/blog/2022-0518-01/Main.php on line 18
$

確かにエラーになる。 さて、PHP 7.4.29での実行結果に「Use isset() or property_exists() instead」とあるので、その辺を検証してみる。

<?php

printf("%s\n", PHP_VERSION);

ini_set('display_errors', '1');
ini_set('error_reporting', E_ALL);

class A {
}

$base = array(
    'isNull' => null,
    'isZero' => 0,
    'isOne' => 1,
    'isStr0' => '0',
    'isEmptyStr' => '',
    'isStrHoge' => 'hoge',
);

$obj = new A();
foreach ($base as $k => $v) {
    $obj->$k = $v;
}
$ary = $base;

var_dump($obj, $ary);

foreach ($base as $k => $v) {
    printf("%-12s: %d %d %d %d\n",
        $k,
        array_key_exists($k, $ary),
        property_exists($obj, $k),
        isset($ary[$k]),
        isset($obj->$k));
}
$k = 'noExistence';
printf("%-12s: %d %d %d %d\n",
    $k,
    array_key_exists($k, $ary),
    property_exists($obj, $k),
    isset($ary[$k]),
    isset($obj->$k));

これを同様に実行してみると、以下のようになる。

$ php56 Test.php
5.6.40
object(A)#1 (6) {
  ["isNull"]=>
  NULL
  ["isZero"]=>
  int(0)
  ["isOne"]=>
  int(1)
  ["isStr0"]=>
  string(1) "0"
  ["isEmptyStr"]=>
  string(0) ""
  ["isStrHoge"]=>
  string(4) "hoge"
}
array(6) {
  ["isNull"]=>
  NULL
  ["isZero"]=>
  int(0)
  ["isOne"]=>
  int(1)
  ["isStr0"]=>
  string(1) "0"
  ["isEmptyStr"]=>
  string(0) ""
  ["isStrHoge"]=>
  string(4) "hoge"
}
isNull      : 1 1 0 0
isZero      : 1 1 1 1
isOne       : 1 1 1 1
isStr0      : 1 1 1 1
isEmptyStr  : 1 1 1 1
isStrHoge   : 1 1 1 1
noExistence : 0 0 0 0
$ 
$ php74 Test.php
7.4.29
object(A)#1 (6) {
  ["isNull"]=>
  NULL
  ["isZero"]=>
  int(0)
  ["isOne"]=>
  int(1)
  ["isStr0"]=>
  string(1) "0"
  ["isEmptyStr"]=>
  string(0) ""
  ["isStrHoge"]=>
  string(4) "hoge"
}
array(6) {
  ["isNull"]=>
  NULL
  ["isZero"]=>
  int(0)
  ["isOne"]=>
  int(1)
  ["isStr0"]=>
  string(1) "0"
  ["isEmptyStr"]=>
  string(0) ""
  ["isStrHoge"]=>
  string(4) "hoge"
}
isNull      : 1 1 0 0
isZero      : 1 1 1 1
isOne       : 1 1 1 1
isStr0      : 1 1 1 1
isEmptyStr  : 1 1 1 1
isStrHoge   : 1 1 1 1
noExistence : 0 0 0 0
$ 
$ php81 Test.php
8.1.6
object(A)#1 (6) {
  ["isNull"]=>
  NULL
  ["isZero"]=>
  int(0)
  ["isOne"]=>
  int(1)
  ["isStr0"]=>
  string(1) "0"
  ["isEmptyStr"]=>
  string(0) ""
  ["isStrHoge"]=>
  string(4) "hoge"
}
array(6) {
  ["isNull"]=>
  NULL
  ["isZero"]=>
  int(0)
  ["isOne"]=>
  int(1)
  ["isStr0"]=>
  string(1) "0"
  ["isEmptyStr"]=>
  string(0) ""
  ["isStrHoge"]=>
  string(4) "hoge"
}
isNull      : 1 1 0 0
isZero      : 1 1 1 1
isOne       : 1 1 1 1
isStr0      : 1 1 1 1
isEmptyStr  : 1 1 1 1
isStrHoge   : 1 1 1 1
noExistence : 0 0 0 0
$ 

いずれも「nullが代入されたpropertyが存在する」時にisset()とproperty_exists()の挙動が異なる。

すなわち、厳密には、オブジェクトに対するarray_key_exists関数の呼び出しはproperty_exists関数でしか代用できない。

令和4年3月21日

ということなので、遊んでみる。

import java.util.Calendar;
import java.util.Locale;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class Main {
    public static void main(String[] args) {
        Locale locale = new Locale("ja", "JP", "JP");
        Calendar cal = Calendar.getInstance(locale);
        DateFormat df = new SimpleDateFormat("GGGGy年M月d日", locale);
        System.out.println(df.format(cal.getTime()));
    }
}
$ java Main
令和4年3月21日
$ 

わーい。