首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么找不到IntlDateFormatter?

为什么找不到IntlDateFormatter?
EN

Stack Overflow用户
提问于 2015-04-09 14:57:45
回答 1查看 3.5K关注 0票数 1

加载了php-intl扩展,因为我可以在视图脚本中使用IntlDateFormatter::SHORT,没有问题。

在我的ViewHelper中

代码语言:javascript
复制
<?php

namespace Common\View\Helper;

use Zend\View\Helper\AbstractHelper;

class DateFormat extends AbstractHelper {

    public function __invoke($dateField) {
        $dateFormatter=$this->getView()->plugin('dateformat');        
        return $dateFormatter(strtotime($dateField),       IntlDateFormatter::SHORT);  
    }
}
?>

我知道错误了

致命错误:在第12行的C:\TEMP\zf2ad\client\module\Common\src\Common\View\Helper\DateFormat.php中找不到“公共\视图\Helper\IntlDateFor事宜”类

请指教

以法莲

EN

回答 1

Stack Overflow用户

发布于 2015-04-09 15:09:51

因为您在命名空间上下文中工作,所以它在实际的命名空间Common\View\Helper中查找类。如果类位于全局命名空间中,则必须在类前面添加反斜杠。

代码语言:javascript
复制
return $dateFormatter(strtotime($dateField), \IntlDateFormatter::SHORT);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29542011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档