OPP 命名问题:object->function($param)

发布于 2024-11-25 06:10:31 字数 315 浏览 3 评论 0原文

在 OOP 中,当你这样做时,该怎么称呼它:

$o = new ClassInstance();

$o->someFunction($p);

例如,我会说我将参数 p 传递给函数 someFunction。简单的。

但是如何清楚调用类对象 ClassInstance 中的函数呢?您并没有真正将函数 someFunction 传递给对象 ClassInstance...所以您会说:“在 ClassInstance 对象中调用 someFunction 函数吗?”

谢谢。

In OOP, what do call it when you do:

$o = new ClassInstance();

$o->someFunction($p);

For example, I would say I'm passing the parameter p to the function someFunction. Easy.

But how do you articulate the calling of a function in the class object, ClassInstance? You're not really passing the function someFunction to the object ClassInstance.... so would you say: "Call the someFunction function in the ClassInstance object?"

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素罗衫 2024-12-02 06:10:31

“从对象 $o(它是类 ClassInstance 的实例)调用方法 someFunction,将 $p 传递为一个论点。”

为了清楚起见,重新表述一下:

$instance = new ClassName();
$instance->someMethod($p);

“从对象 $instance(它是类 ClassName 的实例)调用方法 someMethod,传递 $p< /code> 作为参数(或参数)”。

"Call method someFunction from object $o (which is an instance of class ClassInstance), passing $p as an argument.".

Rephrasing for clarity:

$instance = new ClassName();
$instance->someMethod($p);

"Call method someMethod from object $instance (which is an instance of class ClassName), passing $p as a parameter (or argument)".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文