original_string: public static function getBrowserLanguage($browserLang = null)
      {
          static $replacementPatterns = array(
              // extraneous bits of RFC 3282 that we ignore
              '/(\\\\.)/', // quoted-pairs
              '/(\s+)/', // CFWcS white space
              '/(\([^)]*\))/', // CFWS comments
              '/(;q=[0-9.]+)/', // quality
  
              // found in the LANG environment variable
              '/\.(.*)/', // charset (e.g., en_CA.UTF-8)
              '/^C$/', // POSIX 'C' locale
          );
  
          if (is_null($browserLang)) {
              $browserLang = self::sanitizeInputValues(@$_SERVER['HTTP_ACCEPT_LANGUAGE']);
              if (empty($browserLang) && self::isPhpCliMode()) {
                  $browserLang = @getenv('LANG');
              }
          }
  
          if (empty($browserLang)) {
              // a fallback might be to infer the language in HTTP_USER_AGENT (i.e., localized build)
              $browserLang = "";
          } else {
              // language tags are case-insensitive per HTTP/1.1 s3.10 but the region may be capitalized per ISO3166-1;
              // underscores are not permitted per RFC 4646 or 4647 (which obsolete RFC 1766 and 3066),
              // but we guard against a bad user agent which naively uses its locale
              $browserLang = strtolower(str_replace('_', '-', $browserLang));
  
              // filters
              $browserLang = preg_replace($replacementPatterns, '', $browserLang);
  
              $browserLang = preg_replace('/((^|,)chrome:.*)/', '', $browserLang, 1); // Firefox bug
              $browserLang = preg_replace('/(,)(?:en-securid,)|(?:(^|,)en-securid(,|$))/', '$1', $browserLang, 1); // unregistered language tag
  
              $browserLang = str_replace('sr-sp', 'sr-rs', $browserLang); // unofficial (proposed) code in the wild
          }
  
          return $browserLang;
      }
code: public static function getBrowserLanguage($browserLang = null)
      {
          static $replacementPatterns = array(
              // extraneous bits of RFC 3282 that we ignore
              '/(\\\\.)/', // quoted-pairs
              '/(\s+)/', // CFWcS white space
              '/(\([^)]*\))/', // CFWS comments
              '/(;q=[0-9.]+)/', // quality
  
              // found in the LANG environment variable
              '/\.(.*)/', // charset (e.g., en_CA.UTF-8)
              '/^C$/', // POSIX 'C' locale
          );
  
          if (is_null($browserLang)) {
              $browserLang = self::sanitizeInputValues(@$_SERVER['HTTP_ACCEPT_LANGUAGE']);
              if (empty($browserLang) && self::isPhpCliMode()) {
                  $browserLang = @getenv('LANG');
              }
          }
  
          if (empty($browserLang)) {
              // a fallback might be to infer the language in HTTP_USER_AGENT (i.e., localized build)
              $browserLang = "";
          } else {
              // language tags are case-insensitive per HTTP/1.1 s3.10 but the region may be capitalized per ISO3166-1;
              // underscores are not permitted per RFC 4646 or 4647 (which obsolete RFC 1766 and 3066),
              // but we guard against a bad user agent which naively uses its locale
              $browserLang = strtolower(str_replace('_', '-', $browserLang));
  
              // filters
              $browserLang = preg_replace($replacementPatterns, '', $browserLang);
  
              $browserLang = preg_replace('/((^|,)chrome:.*)/', '', $browserLang, 1); // Firefox bug
              $browserLang = preg_replace('/(,)(?:en-securid,)|(?:(^|,)en-securid(,|$))/', '$1', $browserLang, 1); // unregistered language tag
  
              $browserLang = str_replace('sr-sp', 'sr-rs', $browserLang); // unofficial (proposed) code in the wild
          }
  
          return $browserLang;
      }
code_tokens: public static function getBrowserLanguage ( $ browserLang = null ) { static $ replacementPatterns = array ( // extraneous bits of RFC 3282 that we ignore '/(\\\\.)/' , // quoted-pairs '/(\s+)/' , // CFWcS white space '/(\([^)]*\))/' , // CFWS comments '/(;q=[0-9.]+)/' , // quality // found in the LANG environment variable '/\.(.*)/' , // charset (e.g., en_CA.UTF-8) '/^C$/' , // POSIX 'C' locale ) ; if ( is_null ( $ browserLang ) ) { $ browserLang = self :: sanitizeInputValues ( @ $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ; if ( empty ( $ browserLang ) && self :: isPhpCliMode ( ) ) { $ browserLang = @ getenv ( 'LANG' ) ; } } if ( empty ( $ browserLang ) ) { // a fallback might be to infer the language in HTTP_USER_AGENT (i.e., localized build) $ browserLang = "" ; } else { // language tags are case-insensitive per HTTP/1.1 s3.10 but the region may be capitalized per ISO3166-1; // underscores are not permitted per RFC 4646 or 4647 (which obsolete RFC 1766 and 3066), // but we guard against a bad user agent which naively uses its locale $ browserLang = strtolower ( str_replace ( '_' , '-' , $ browserLang ) ) ; // filters $ browserLang = preg_replace ( $ replacementPatterns , '' , $ browserLang ) ; $ browserLang = preg_replace ( '/((^|,)chrome:.*)/' , '' , $ browserLang , 1 ) ; // Firefox bug $ browserLang = preg_replace ( '/(,)(?:en-securid,)|(?:(^|,)en-securid(,|$))/' , '$1' , $ browserLang , 1 ) ; // unregistered language tag $ browserLang = str_replace ( 'sr-sp' , 'sr-rs' , $ browserLang ) ; // unofficial (proposed) code in the wild } return $ browserLang ; }
docstring: Returns the browser language code, eg. "en-gb,en;q=0.5"
  
  @param string|null $browserLang Optional browser language, otherwise taken from the request header
  @return string
docstring_tokens: Returns the browser language code eg . en - gb en ; q = 0 . 5