目次 |
---|
・クラスのメンバ変数 ・親クラスのメンバ変数を子クラスから使用する |
<?php class sample01{ var $tm = 60 * 60 * 24; function msg(){ echo $this->tm; } } ?>
<?php class sample01{ var $tm = date("Y/m/d H:i:s"); function msg(){ echo $this->tm; } } ?>
<?php class sample02{ var $msg = array("test1","test2"); // コンストラクタ function sample02(){ print_r($this->msg); } } $a = new sample02(); ?>
<?php class sample03{ var $msg = "test"; function print_out(){ print_r($this->msg); } } class sample04 extends sample03{ function prints(){ parent::print_out(); } } $a = new sample04(); $a->prints(); ?>
test