以下の内容はhttps://r9.hateblo.jp/entry/2015/02/09/235142より取得しました。


PHPのオブジェクトはnewできる

なんか動いたのでメモ。

<?php
class Hoge {
    public $str;
    public function __construct($str) {
        echo "__construct() is called.\n";
        $this->str = $str;
    }
}

$hoge = new Hoge("hoge");
print_r($hoge);

$fuga = new $hoge("fuga"); // ★オブジェクトにnewする
print_r($fuga);
__construct() is called.
Hoge Object
(
    [str] => hoge
)

__construct() is called.
Hoge Object
(
    [str] => fuga
)

new selfとか、new staticが動くからかな。




以上の内容はhttps://r9.hateblo.jp/entry/2015/02/09/235142より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14