English 中文(简体)
提及一子类别的固定成员
原标题:Referring to a static member of a subclass
  • 时间:2011-01-28 13:55:38
  •  标签:
  • php
  • oop

我希望有一个<代码>。 关键词将使该代码在打印<编码> 价值以下。 如果有的话,我很想知道,现在是否有办法提及一位子类成员?

class Main
{
    static function foo()
    {
        echo sub::$variable;
    }
}

class Sub extends Main
{
    static $variable = "value";
}

Sub::foo();
最佳回答

我认为,你正在寻找<代码>static:$variable。 这部名为Late Static Brel,可在PHP5.3中查阅。

问题回答

暂无回答




相关问题
Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Passing another class amongst instances

I was wondering what is the best practice re. passing (another class) amongst two instances of the same class (lets call this Primary ). So, essentially in the constructor for the first, i can ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签