PHP构造函数
<?phpclassa{functiona(){echo"iamtheconstructorofa.<br>\n";}functionb(){echo"iamaregul...
<?php
class a{
function a(){
echo "i am the constructor of a.<br>\n";
}
function b(){
echo "i am a regular function named b in class a.<br>\n";
echo "i am not a constructor in a.<br>\n";
}}
class b extends a
{
function c(){
echo"i am a regular function.<br>\n";
}}
$b=new b;
?>
为什么最后只输出“i am the constructor of a.”这些函数是怎样调用的?
怎么说class b中没有构造函数,什么是构造函数? 展开
class a{
function a(){
echo "i am the constructor of a.<br>\n";
}
function b(){
echo "i am a regular function named b in class a.<br>\n";
echo "i am not a constructor in a.<br>\n";
}}
class b extends a
{
function c(){
echo"i am a regular function.<br>\n";
}}
$b=new b;
?>
为什么最后只输出“i am the constructor of a.”这些函数是怎样调用的?
怎么说class b中没有构造函数,什么是构造函数? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询