I'm trying to get the current selected language.

Here is the part of my code:

    define('_JEXEC', 1);
    define('DS', DIRECTORY_SEPARATOR);
    
    if (file_exists(dirname(__FILE__) . '/defines.php')) {
        include_once dirname(__FILE__) . '/defines.php';
    }
    
    if (!defined('_JDEFINES')) {
        define('JPATH_BASE', dirname(__FILE__));
        require_once JPATH_BASE.'/includes/defines.php';
    }
    
    require_once JPATH_BASE.'/includes/framework.php';
    
    $lang =& JFactory::getLanguage()->getTag();

and...

    echo $lang;

allways returns en-GB.

The website has the possibility of Ger and Eng. It also changes languages for different articles. I don't understand how I did not get the current selected language within php.