调用子类的方法 [英] Calling a subclass's method
问题描述
你好
我是PHP新手,我有这个问题:
我有一个名为表单,包含一组类
(对象)称为文本框。
现在我需要调用Textbox类的方法getOuterHTML(在Windows中,你应该这样做:
oForm.getTextBoxByID(" Number")。getOuterHTML()
在PHP中我试过这个:$ oForm-> getTextBoxByID(" Number") - > getOuterHTML();
但是这不起作用...
有没有办法在一个声明中这样做? (我使用PHP4)。
提前致谢!
Ramon。
oForm - > getTextBoxByID(" Number") - > getOuterHTML();
但这不起作用......
有没有在一个声明中这样做的方式? (我使用PHP4)。
提前致谢!
Ramon。
Ramon写道:你好
我是PHP的OOP新手,我有这个问题:
我有一个名为Form的类,其中包含一个集合类的名称
(对象)称为文本框。
现在我需要调用Textbox类的方法getOuterHTML()。
在Visual Basic中你应该这样做:
oForm.getTextBoxByID(" Number")。getOuterHTML()
在PHP中我试过这个:
oForm-> getTextBoxByID(" Number") - > getOuterHTML();
但那不起作用......
有没有办法在一个语句中执行此操作? (我使用PHP4)。
你如何反对包含文本框,以及你如何定义
方法getTextBoxByID?
我不是真正的OOP程序员,但在这种情况下我会:
<?php
B级{
功能显示(){
echo" works";
}
}
A级{
var
Hello
I''m new to OOP in PHP and I have this question:
I have a class called "Form", which contains a collection of classes
(objects) called "Textbox".
Now I need to call the Textbox class''s method "getOuterHTML()".
In Visual Basic, you should do it like this:
oForm.getTextBoxByID("Number").getOuterHTML()
In PHP I tried this: $oForm->getTextBoxByID("Number")->getOuterHTML();
But that doesn''t work...
Is there a way to do this in one statement? (I use PHP4).
Thanks in advance!
Ramon.
oForm->getTextBoxByID("Number")->getOuterHTML();
But that doesn''t work...
Is there a way to do this in one statement? (I use PHP4).
Thanks in advance!
Ramon.
Ramon wrote:Hello
I''m new to OOP in PHP and I have this question:
I have a class called "Form", which contains a collection of classes
(objects) called "Textbox".
Now I need to call the Textbox class''s method "getOuterHTML()".
In Visual Basic, you should do it like this:
oForm.getTextBoxByID("Number").getOuterHTML()
In PHP I tried this:
oForm->getTextBoxByID("Number")->getOuterHTML();
But that doesn''t work...
Is there a way to do this in one statement? (I use PHP4).
How does you object "contain" the textboxes, and how have you defined the
method getTextBoxByID?
I''m no real OOP programmer, but in this case I''d:
<?php
class B{
function display(){
echo "works";
}
}
class A{
var
这篇关于调用子类的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!