Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file

Once Installed Magento 2.x & try to open frontend & backend & getting below error

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'D:/xampp/htdocs/mage244/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml' in module: 'Magento_Backend' block's name: 'require.js'

Solution:: Follow below steps

Step [1] – Open file Validator.php below path

Magento2.x_base-path\vendor\magento\framework\View\Element\Template\File

Step [2] – Go To Function — protected function isPathInDirectories($path, $directories) & replace with below code

protected function isPathInDirectories($path, $directories) {

	$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

	if (!is_array($directories)) 

	{ $directories = (array)$directories; } 

	foreach ($directories as $directory) { 

	if (0 === strpos($realPath, $directory)) 

	{ return true; } 

	} return false; 

	}

Step [3] – Finally Save File & run below command & issue will resolved

php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy -f && php bin/magento indexer:reindex && php bin/magento cache:flush