Magento 2 has multiple methods to get Currency symbol.You can get it from Dependency Injection, or by ObjectManager. My preferred method is Dependency Injection, but you can also do it by ObjectManager. Remember: try to avoid the ObjectManager method because it is not a good practice for learning. But in given below examples you can see in both filter method.
By Dependency Injection
protected $CurrencySymbol; public function __construct( \Magento\Framework\Locale\CurrencyInterface $CurrencySymbol ) { $this->CurrencySymbol= $CurrencySymbol; } Now you can use below code in your function to get currency symbol. $CurrencyCode='USD'; $this->CurrencySymbol->getCurrency($CurrencyCode)->CurrencyCode();
By ObjectManager
$ObjectManager = \Magento\Framework\App\ObjectManager::getInstance(); $CurrencyCode='USD'; $Symbol = $ObjectManager ->create('Magento\Directory\Model\CurrencyFactory')->create()->load($CurrencyCode); echo $Symbol ->getCurrencySymbol();
By ObjectManager, you can get currency symbol in phtml file also.
Run php bin/magento setup:di:compile when you add any dependency injection. Because without php bin/magento setup:di:compile it throws error in code.
Hope this will helps you!