本文整理汇总了PHP中MyClass::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP MyClass::__construct方法的具体用法?PHP MyClass::__construct怎么用?PHP MyClass::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyClass
的用法示例。
在下文中一共展示了MyClass::__construct方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MyDerivedClass
function MyDerivedClass()
{
parent::__construct();
$this->pub_new = "pub_new value";
$this->prot_new = "prot_new value";
$this->priv_new = "priv_new value";
}
示例2:
function __construct($a)
{
parent::__construct();
$this->pub = $this->prot . $a;
}
示例3:
function __construct()
{
parent::__construct();
print "In SubClass constructor\n";
}
示例4: __construct
public function __construct()
{
parent::__construct();
echo "A new constructor in " . __CLASS__ . ".<br />";
}
示例5: __construct
public function __construct()
{
parent::__construct();
echo "the class " . __CLASS__ . " was started --- contructor extended" . "<br/>";
}
示例6: __construct
public function __construct()
{
parent::__construct();
$this->id = self::$cnt++;
echo 'Daughter #' . $this->id . PHP_EOL;
}
示例7: __construct
public function __construct()
{
/*
Preserving Original Method Functionality While Overwriting Methods
To add new functionality to an inherited method while keeping the original method intact, use the parent keyword with the scope resolution operator (::):
*/
parent::__construct();
// Call the parent class's constructor
echo "A new constructor in " . __CLASS__ . ".<br />";
}