PHP中的多态性 [英] Polymorphism in PHP

查看:50
本文介绍了PHP中的多态性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!我正在与一些合作伙伴(我们大学的
)合作开发PHP和MySQL,我们正在考虑构建一些类和

使用继承和多态。


问题是我们不确定PHP实现多态性

我们无法找到有关它的信息。我真的很感激如果有人可以给我们一些关于某些书籍的建议来阅读

关于它和/或寻找一些信息的页面。


谢谢大家。


PD:我来自阿根廷,所以我的真实语言是西班牙语。我是英语的有效阅读,但我的写作必须改进。 = P

Hello! I am working with PHP and MySQL in a proyect with some partners
of our university, and we are thinking about building some classes and
use inheritance and polymorphism.

The problem is that we are not sure of PHP implementing polymorphism
and we couldn''t find info about it. I will really appreciate if
someone could give us some recommendations about some books to read
about it and/or pages to look for some info.

Thanks for all.

PD: I am from Argentina, so my real language is Spanish. I am
effective reading in English, but my writing has to be improved. =P

推荐答案




2004年4月20日18:42:55 -0700,< a href =mailto:ga ********** @ hotmail.com> ga ********** @ hotmail.com (Gurtaj)

写道:
Hi,

On 20 Apr 2004 18:42:55 -0700, ga**********@hotmail.com (Gurtaj)
wrote:
你好!我正在与我们大学的一些合作伙伴合作开发PHP和MySQL,我们正在考虑构建一些类和
使用继承和多态。

问题是我们不确定PHP实现多态性
我们无法找到它的信息。我真的很感激,如果有人可以给我们一些关于某些书籍的建议,请阅读
关于它和/或寻找一些信息的页面。


尝试 www.php.net ,它解释了这些课程如何运作良好。


多态性示例:


class doer {


函数do();


}


类do_b扩展doer {


函数do( ){

打印我正在做b;

}

}


class do_c extends doer {


function do(){

print"我正在做c" ;;

}

}
Hello! I am working with PHP and MySQL in a proyect with some partners
of our university, and we are thinking about building some classes and
use inheritance and polymorphism.

The problem is that we are not sure of PHP implementing polymorphism
and we couldn''t find info about it. I will really appreciate if
someone could give us some recommendations about some books to read
about it and/or pages to look for some info.
Try www.php.net, it explains how the classes work quite well.

Example Polymorphism:

class doer{

function do();

}

class do_b extends doer{

function do(){
print "I''m doing b";
}
}

class do_c extends doer{

function do(){
print "I''m doing c";
}
}


sample_doer = get_a_sample_doer_somehow();

sample_doer = get_a_sample_doer_somehow();


sample_doer-> do();


什么也没做(上课),我正在做b,我正在做c,

取决于你实例化的内容。


PHP4没有的东西是抽象,公共,私有的声明,

你必须通过适当的合作覆盖ding和调试机制。


重新定义构造函数也没有工作,这有点痛苦。


HTH,Jochen


感谢所有人。

PD:我来自阿根廷,所以我的真实语言是西班牙语。我有效阅读英文,但我的写作必须改进。 = P
sample_doer->do();

does either nothing (class doer), "I''m doing b", "I''m doing c",
depending on what you instantiated.

What PHP4 doesn;t have is declarations like abstract, public, private,
you have to cover that by proper coding and debugging mechanisms.

Also redefining constructors doesn;t work, which is a bit of a pain.

HTH, Jochen



Thanks for all.

PD: I am from Argentina, so my real language is Spanish. I am
effective reading in English, but my writing has to be improved. =P




-

Jochen Daum - Cabletalk Group Ltd.

PHP DB编辑工具包 - PHP用于构建的脚本

数据库编辑界面。
http: //sourceforge.net/projects/phpdbedittk/


这篇关于PHP中的多态性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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