ResourceBundle returns NULL without any errors bei

2019-05-08 10:18发布

问题:

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