PHP构造函数

<?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 b中没有构造函数,而b又继承了a ,a中有构造函数,所以实例化b就会自动运行a里的function a
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-08-08
这种PHP4方式的OO还是建议抛弃把。用__construct

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网