ResourceBundle returns NULL without any errors being raised

ⅰ亾dé卋堺 提交于 2019-12-07 08:55:14

问题


For internationalized data it would be great to work with the \ResourceBundle class from PHP's "intl" extension.

I got the extension running (PHP 5.3.4; Windows) and created a .dat file using the ICU Data Library Customizer*, but I don't get the expected result from the resource bundle class.

Now I do this

$bundle   = '/var/www/libs/icudt48l.dat';
$resource = new \ResourceBundle('en_US', $bundle, true);
var_dump($resource, is_file($bundle)); //--> NULL, TRUE

The problem is $resource returns NULL without any errors being raised. What's going on?

*(Only the last two data sections were checked—base data is always included—and I exported it as ICU4C)


回答1:


<?php
$b = '/var/www/libs/icudt48l';
$r = new \ResourceBundle('en_US', $b, true);
var_dump($r instanceof \ResourceBundle); //-> TRUE

the .dat extension should be left to make it work




回答2:


try $resource = resourcebundle_create('en_US',$bundle,true);



来源:https://stackoverflow.com/questions/6256937/resourcebundle-returns-null-without-any-errors-being-raised

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!