我需要什么
我需要将国家/地区代码转换为货币符号。
like for USD => $.
我需要将货币代码转换为货币符号。
代码
控制器
use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
class EventDetailController extends Controller
{
$currency = $data[0]['currency'];
$Currency= USD
Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencySymbol('USD');
}
错误
PHP Fatal error: Class 'Acme\\biztradeshowsBundle\\Controller\\Symfony\\Component\\Intl\\Intl' not found in /home/indiamart/public_html/10into/src/Acme/biztradeshowsBundle/Controller/EventDetailController.php on line 180
答案 0 :(得分:2)
你应该写use
声明:
use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
use Symfony\Component\Intl\Intl;
class EventDetailController extends Controller
{
$currency = $data[0]['currency'];
$Currency= USD
Intl::getCurrencyBundle()->getCurrencySymbol('USD');
}
或使用前导斜杠写下你的FQCN:
use Symfony\Component\Intl\ResourceBundle\CurrencyBundle;
class EventDetailController extends Controller
{
$currency = $data[0]['currency'];
$Currency= USD
\Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencySymbol('USD');
}