I have created a custom variable from magento 2 admin (System > Custom Variables). My custom variable code is "test_var".
How can I get that value in a phtml file?
for this you have to use object Manager and load model using its variable Code
After that you can get its plain value, html value and its name too.
<?php
$model = $this->_objectManager->get('Magento\Variable\Model\Variable')->loadByCode('test_var');
$plain_value = $model->getPlainValue();
$html_value = $model->getHtmlValue();
$name = $model->getName();
?>