最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

php的構(gòu)造函數(shù)

<?php

class Car {

? ? //增加構(gòu)造函數(shù)與析構(gòu)函數(shù)

? ? function __construct(){

? ? print "construct parent"; ? ?

? ? }

? ? function __destruct(){

? ? print "\ndestruct parent"; ?

? ? }

? ??

}

class Truck extends Car{

? ? function __construct(){

? ? ? ??

? ? ? ? print "child";

? ? ? ??

? ? ? ? parent:: __construct();

? ? ? ??

? ? ? ??

? ? }

}

$car = new Car();

為什么打印出來(lái)的是

construct parent
destruct parent,

而沒(méi)有打印child

正在回答

5 回答

$car = new Truck();

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

FINE_Android 提問(wèn)者

非常感謝!
2017-04-21 回復(fù) 有任何疑惑可以回復(fù)我~

要實(shí)例化Truck(),而不是實(shí)例化Car()

0 回復(fù) 有任何疑惑可以回復(fù)我~

$car = new Truck();

0 回復(fù) 有任何疑惑可以回復(fù)我~

你 new 錯(cuò)了。

0 回復(fù) 有任何疑惑可以回復(fù)我~

竟然犯這樣低級(jí)的錯(cuò)誤

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

php的構(gòu)造函數(shù)

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)