我怎么'使用'IteratorAggregate接口,PHP找不到它? [英] How do I 'use' the IteratorAggregate interface, PHP can't find it?

查看:422
本文介绍了我怎么'使用'IteratorAggregate接口,PHP找不到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我想要实现IteratorAggregate的类。我声明:

I have a class that I want to implement IteratorAggregate. I declare:

class Email implements IteratorAggregate {

但当我输入代码时我得到:

but when I rung the code I get:


尝试加载IteratorAggregate接口namespace
Companyname\ConsoleBundle\ Entity。您是否忘记了另一个名称空间的使用语句

Attempted to load interface "IteratorAggregate" from namespace "Companyname\ConsoleBundle\Entity". Did you forget a "use" statement for another namespace?

那么我应该添加什么名称空间来实现'' IteratorAggregate'界面。我见过的所有例子都没有包含任何使用或需要声明,它应该作为标准包含在PHP5中,所以这不是安装问题。

So what name space should I adding to implelement the 'IteratorAggregate' interface. None of the examples I've seen include any use or require statements for it and it should be included as standard in PHP5 so it's not an installation issue.

任何想法是什么我做错了?

Any ideas what I'm doing wrong?

推荐答案

当您使用自己的命名空间并且想要使用标准类,你必须像这样拼写

When you use your own namespace and you want to use a standard class, you have to spell it like this

class Email implements \IteratorAggregate {

这篇关于我怎么'使用'IteratorAggregate接口,PHP找不到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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