"构造"在/用于功能? [英] "construct" in/for functions?

查看:64
本文介绍了"构造"在/用于功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我想知道是否有可能有类似__ construct()的东西。对于PHP中的函数/方法?


例如

< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号

解决方案

在你的x :: x()方法中,你可以调用x :: y()方法。

展开 | 选择 | Wrap | 行号 < /块引用>
嗨!谢谢你的回复!


然而,这并不是我想的,


我正在寻找的是一种方式确保方法x(),而不需要在x()中手动调用y(),将访问y(),


即相当于这样做(其中)整个类y基本上表示前一示例中的方法y:

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


呃,不,据我所知,这是不可能的。我不明白为什么你也想要这样做,但那既不在这里也不在那里。


你是但是使用PHP4语法。查看 PHP5 的模型。


Hello,

I am wondering if it is possible to have something like "__construct()" for functions/methods in PHP?

e.g.

Expand|Select|Wrap|Line Numbers

解决方案

In your x::x() method, you could call the x::y() method.

Expand|Select|Wrap|Line Numbers


Hi! thanks for your reply!

However, that was not exactly what I was thinking about,

what I am looking for is a way to make sure that method x(), without the need to manually call y() within x(), will access y(),

that is, the equivalent to doing this (where the entire class "y" is basically representing the method "y" in the previous example):

Expand|Select|Wrap|Line Numbers


Uh, no, as far as I know, that is not possible. I don''t understand why you''d want to do that either, but that''s neither here nor there.

You''re using PHP4 syntax though. Check out PHP5''s model.


这篇关于&QUOT;构造&QUOT;在/用于功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆