码迷,mamicode.com
首页 > 其他好文 > 详细

Constructors and Destructors

时间:2015-05-04 15:16:54      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:

Constructor

void __construct ([mixed $args = ""[, $... ]])
void __destruct ( void )

  parent::__construct() to run a parent constructor

<?php
class BaseClass {
   function __construct() {
       print "In BaseClass constructor\n";
   }
}

class SubClass extends BaseClass {
   function __construct() {
       parent::__construct();
       print "In SubClass constructor\n";
   }
}

class OtherSubClass extends BaseClass {
    // inherits BaseClass‘s constructor
}

// In BaseClass constructor
$obj = new BaseClass();

// In BaseClass constructor
// In SubClass constructor
$obj = new SubClass();

// In BaseClass constructor
$obj = new OtherSubClass();
?>

 

  

Constructors and Destructors

标签:

原文地址:http://www.cnblogs.com/iMirror/p/4476190.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!