【问题标题】:Why is IntlDateFormatter not found?为什么找不到 IntlDateFormatter?
【发布时间】:2015-04-09 14:57:45
【问题描述】:

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

我的 ViewHelper 中的位

<?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);  
    }
}
?>

我得到了错误

致命错误:在中找不到类“Common\View\Helper\IntlDateFormatter” C:\TEMP\zf2ad\client\module\Common\src\Common\View\Helper\DateFormat.php 在第 12 行

请指教

以法莲

【问题讨论】:

    标签: php zend-framework2 view-helpers


    【解决方案1】:

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

    return $dateFormatter(strtotime($dateField), \IntlDateFormatter::SHORT);
    

    【讨论】:

      猜你喜欢
      • 2016-05-15
      • 2011-09-08
      • 2019-05-15
      • 1970-01-01
      • 2011-06-17
      • 2020-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多