当我运行这段代码时,我得到了我不明白的东西 [英] When I run this code I get what I don't understand
本文介绍了当我运行这段代码时,我得到了我不明白的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
class Cars {
static $wheel_count = 4;
static $door_count = 2;
static function car_detail(){
return self::$wheel_count;
return self::$door_count;
}
}
class Trucks extends Cars {
static function display(){
echo parent::car_detail();
}
}
Trucks::display();
?>
我尝试了什么:
您好,我有一个问题,我是PHP的新手,当我运行此代码时,我有结果4.为什么我没有4和2,我运行功能显示得到wheel_count和door_count,为什么我只有wheel_count 4?
What I have tried:
Hello, i have a question please, i'm a newbie on PHP and when i run this code i have as result 4.Why i don't have 4 and 2, i ran the function display to get wheel_count and door_count, so why i have just wheel_count 4 ?
推荐答案
wheel_count = 4 ;
static
wheel_count = 4; static
door_count = 2 ;
静态函数car_detail(){
return self ::
door_count = 2; static function car_detail(){ return self::
wheel_count;
return self ::
wheel_count; return self::
这篇关于当我运行这段代码时,我得到了我不明白的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文