Dab tsi yog super lo lus tseem ceeb hauv PHP?
Dab tsi yog super lo lus tseem ceeb hauv PHP?

Video: Dab tsi yog super lo lus tseem ceeb hauv PHP?

Video: Dab tsi yog super lo lus tseem ceeb hauv PHP?
Video: Nkauj Qhua Tsawg Ib Lo Lus Music 🎶 video 2024, Kaum ib hlis
Anonim

Cov super lo lus tseem ceeb hais txog superclass (niam txiv) khoom. Nws yog siv los hu rau superclass txoj kev, thiab nkag mus rau lub superclass constructor.

Ib yam li ntawd, lo lus super lo lus piav qhia nrog piv txwv yog dab tsi?

1) super yog siv los xa cov niam txiv tam sim hauv chav kawm piv txwv hloov pauv. Peb tuaj yeem siv tau super lo lus tseem ceeb mus saib tau cov ntaub ntawv tus tswv cuab los yog teb ntawm niam txiv chav kawm. Nws yog siv yog cov chav kawm niam txiv thiab cov menyuam kawm ntawv muaj tib lub teb. Nyob rau saum toj piv txwv , Tsiaj thiab Aub ob chav kawm muaj cov khoom sib xws.

Ib yam li ntawd, PHP super chav kawm yog dab tsi? PHP 5 Keeb kwm. Cov chav kawm uas yog inherited yog hu ua Niam txiv chav kawm (los yog chav kawm super los yog chav kawm hauv paus ) thaum lub sij hawm chav kawm uas yog inheriting lwm yam chav kawm hu ua Child chav kawm (los yog sub chav kawm los yog muab tau chav kawm ). Hauv qhov piv txwv saum toj no, Tib neeg yuav yog tus niam txiv chav kawm thiab Txiv neej thiab poj niam yuav yog nws tus menyuam chav kawm.

Hais txog qhov no, koj txhais li cas los ntawm super lo lus tseem ceeb?

super yog a lo lus tseem ceeb . Nws yog siv nyob rau hauv ib tug sub-chav kawm txujci txhais hu rau ib txoj kev uas tau teev tseg nyob rau hauv lub super chav kawm. Private method of the super -Class hu tsis tau. Tsuas yog pej xeem thiab kev tiv thaiv txoj hauv kev tuaj yeem hu los ntawm super lo lus tseem ceeb . Nws kuj yog siv los ntawm chav tsev tsim kom hu cov neeg tsim tsev ntawm nws cov niam txiv chav kawm.

Qhov txawv ntawm qhov no () thiab super () yog dab tsi?

Qhov sib txawv ntawm super() thiab qhov no () hauv java. super() zoo li no () ob leeg yog siv los ua constructor hu. super() yog siv los hu rau Base class's constructor (ie, Parent's class) thaum qhov no () yog siv los hu rau chav kawm tam sim no tus tsim. super() yog siv hu rau Base class's(Parent class's) constructor.

Pom zoo: