gpt4 book ai didi

php - __construct 和与类同名的函数有什么区别?

转载 作者:IT王子 更新时间:2023-10-29 00:19:54 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
what is the function __construct used for?

__construct 函数和类同名函数有区别吗?

class foo {
function foo ($something){
echo "I see ".$something." argument";
}
}

class bar {
function __construct ($something){
echo "<br />
I see ".$something." argument again";
}
}

$foo = new foo("foo");
$bar = new bar("bar");

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com