PHP中的OOP编组(?) [英] OOP Marshalling(?) in PHP

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

问题描述

我想将两个不同类的功能编组为一个

对象。是否有某种方法可以在PHP中执行此操作?


实际上,我正在尝试执行以下操作:


class clsBread extends clsFlour,clsEggs

I want to marshall the features of two different classes into one
object. Is there a certain way to do this in PHP?

Effectively, I''m trying to do something like:

class clsBread extends clsFlour, clsEggs

推荐答案

7月28日,01:33,Sanders Kaufman< bu ... @ kaufman.netwrote:
On 28 Jul., 01:33, Sanders Kaufman <bu...@kaufman.netwrote:

我想将两个不同类的功能编组为一个

对象。是否有某种方法可以在PHP中执行此操作?


实际上,我正在尝试执行以下操作:


class clsBread extends clsFlour,clsEggs
I want to marshall the features of two different classes into one
object. Is there a certain way to do this in PHP?

Effectively, I''m trying to do something like:

class clsBread extends clsFlour, clsEggs



否,不支持多种继承。


No, mutiple Inheritage is not supported.


.. oO( Sanders Kaufman)
..oO(Sanders Kaufman)

>我想将两个不同类的特征编组成一个
对象。
>I want to marshall the features of two different classes into one
object.



编组是不同的,但无论如何。

Marshalling is something different, but anyway.


>有没有某种方法可以做到这一点在PHP中?

实际上,我正在尝试做类似的事情:

类clsBread扩展clsFlour,clsEggs
>Is there a certain way to do this in PHP?

Effectively, I''m trying to do something like:

class clsBread extends clsFlour, clsEggs



PHP不支持多重继承。但是有一些

概念可以实现类似的效果:


*接口(PHP 5)


< ; http://www.php.net/manual/en/language.oop5.interfaces.php>


*委托/汇总


< http://en.wikipedia.org/wiki/Delegation_(编程)>


Micha

Multiple inheritance is not supported in PHP. But there are some
concepts to accomplish a similar effect:

* interfaces (PHP 5)

<http://www.php.net/manual/en/language.oop5.interfaces.php>

* delegation/aggregation

<http://en.wikipedia.org/wiki/Delegation_(programming)>

Micha


Sanders Kaufman写道:
Sanders Kaufman wrote:

class clsBread extends clsFlour,clsEggs
class clsBread extends clsFlour, clsEggs



class clsBread extends clsFlour

{

公共职能__construct()

{

汇总(

class clsBread extends clsFlour
{
public function __construct ()
{
aggregate(


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

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