I have php file test.php:
use App\Classes\test_class;
$xml = new DOMDocument( "1.0", "ISO-8859-15" );
echo 'DOMDocument-ok<br/>';
$formatter = new NumberFormatter('en_US', NumberFormatter::DECIMAL);
echo 'NumberFormatter-ok<br/>';
new test_class();
And test_class.php:
class test_class{
public function __construct()
{
$xml = new \DOMDocument( "1.0", "ISO-8859-15" );
echo 'DOMDocument-ok<br/>';
$formatter = new \NumberFormatter('en_US', \NumberFormatter::DECIMAL);
echo 'NumberFormatter-ok<br/>';
}
}
When I run this code output is:
DOMDocument-ok
NumberFormatter-ok
DOMDocument-ok
NumberFormatter-ok
But in plugin "sebastian/money" when I use plugin I get this error "Symfony \\ Component \\ Debug \\ Exception \\ FatalErrorException (E_UNKNOWN) HELP Class 'NumberFormatter' not found"
For code:
<?php
namespace SebastianBergmann\Money;
use NumberFormatter;
class IntlFormatter implements Formatter
{
private $numberFormatter;
public function __construct($locale)
{
$this->numberFormatter = new NumberFormatter(
$locale,
NumberFormatter::CURRENCY
);
}
For line :
$this->numberFormatter = new NumberFormatter(
$locale,
NumberFormatter::CURRENCY
);
EDITED:
Apparently NumberFormatter not working inside all Laravel app, but I don't know why, can someone help?
您可以将此用于Laravel http://lyften.com/projects/laravel-currency/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.