duandi6531 2016-01-27 18:59
浏览 16

如果不使用包装类,我可以在PHP中加载多个(非分层)子类吗?

Right now I have a class that gathers and holds information about a specific program that runs in multiple instances on my machine streaming a few radio stations.

What I waned to do was have separate children classes that have different aspects of what I'd want to do. For example

  • Child Class 1, allow sending commands to the running instance
  • Child Class 2, query the program for pulling meta data and playlist history

Now most scripts only would do one of those things, with the except of a few which I'd want to have access to BOTH of the children classes.

Is there any way without having Child 1 extend Child 2 which extends the Parent, to have an instance which includes both children, or is hierarchical the only option in PHP for doing this?

  • 写回答

1条回答 默认 最新

  • dongxi4335 2016-01-27 19:18
    关注

    I think you can move this logic to traits (http://php.net/manual/en/language.oop5.traits.php) and just include them in required classes. Make sense?

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?