扩展2类PHP [英] Extend 2 Classes PHP

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

问题描述

我有3个班级(3个文件):

I have 3 classes (3 files):

a.class.php
b.class.php
c.class.php

我想在类c(文件3)中扩展类a和b:

I want to extend class a and b in the class c (file 3):

我该怎么做?我想在新的C类中同时使用a + b的两个类函数

How I could do that? I want to use both class functions of a + b in my new class C

推荐答案

PHP中没有多重继承.所以你不能那样做.

There is no multiple inheritance in PHP. So you can't do that.

尝试使用合成并重新安排您的班级结构.

Try using composition and re-arranging your class structure.

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

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