主页
PHP
PHP OOP 静态方法
tryphp_static_method4
运行 ❯
×
更改方向
保存代码
更改主题
<!DOCTYPE html> <html> <body> <?php class domain { protected static function getWebsiteName() { return "freew3c.com"; } } class domainW3 extends domain { public $websiteName; public function __construct() { $this -> websiteName = parent::getWebsiteName(); } } $domainW3 = new domainW3; echo $domainW3 -> websiteName; ?> </body> </html>
freew3c.com