$currencyCode = 'USD'; $currency = Currency::getInstanceByID($currencyCode); echo $currency->getName(); // Output: US Dollar
$currencyCode = 'ABC'; $currency = Currency::getInstanceByID($currencyCode); if ($currency !== null) { echo $currency->getName(); } else { echo 'Currency not found'; }In this example, an unknown ISO code is used to get the currency instance. Since there is no matching currency, the method returns null. This condition is checked and an appropriate message is printed on the screen. This method is part of the core PHP library and can be used without any external package/library.