English 中文(简体)
要求家长阶层的方法与静态方法
原标题:Calling a parent classes method vs. calling a static method
  • 时间:2011-10-08 22:09:59
  •  标签:
  • php
  • oop

1. 采用“家长”方法

parent_class::method();  //tested it works

在我使用的即时类别中,用一种方法使用。

$this->method();  //tested it works

然而,如果我从任何一类使用中调用固定方法,则我会使用固定方法。

parent_class::static_method();  //tested it works

我对此表示怀疑,因为b.c. 每一类方法只有一份副本,无论该方法是否即时使用?

有些人能够证实或提供这方面的见解。 我只想核实,无论从哪类静态方法来看,电话方法都是一样的,而且要采用家长班的方法。

见缩略语。

最佳回答

s是正确的。 不清楚你的问题是什么。 如果你想要从儿童内部传给儿童固定的方法,你可以自行使用<代码>:static_method(或$this->static_method(。 两者都会奏效。

问题回答

暂无回答




相关问题
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 ...

热门标签