In this post I am going to explain how to get Magento 2 edition and version.

1. Using Dependency Injection

Add below code snippet in Block class.

protected $_productMetadataInterface;
    
public function __construct(
    \Magento\Framework\View\Element\Template\Context $context,
    \Magento\Framework\App\ProductMetadataInterface $productMetadataInterface,
    array $data = []
) {
    $this->_productMetadataInterface = $productMetadataInterface;
    parent::__construct($context, $data);
}

/* Get Magento 2 Edition */
public function getEdition()
{
    $edition = $this->_productMetadataInterface->getEdition();
    return $edition;
}

/* Get Magento 2 Version */
public function getVersion()
{
    $version = $this->_productMetadataInterface->getVersion();
    return $version;
}

Add below code snippet in template file.

//Get Magento 2 Edition
$edition = $block->getEdition();
echo $edition;


//Get Magento 2 Version
$version = $block->getVersion();
echo $version;

2. Using Object Manager

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$productMetadataInterface = $objectManager->get('Magento\Framework\App\ProductMetadataInterface');

//Get Magento 2 Edition
$edition = $productMetadataInterface->getEdition();
echo $edition;

//Get Magento 2 Version
$version = $productMetadataInterface->getVersion();
echo $version;

It will return edition name like Community or Enterprise and the version like 2.3.5-p1.