public static function getBOM(string $which)
    {
        $cname = self::class . '::' . strtoupper($which) . '_BOM';
        if (!defined($cname))
            return null;

        $bytes = constant($cname);
        $bom = '';
        foreach ($bytes as $ord)
            $bom .= chr($ord);
        return $bom;
    }
public static function getBOM(string $which)
    {
        $cname = self::class . '::' . strtoupper($which) . '_BOM';
        if (!defined($cname))
            return null;

        $bytes = constant($cname);
        $bom = '';
        foreach ($bytes as $ord)
            $bom .= chr($ord);
        return $bom;
    }
public static function getBOM ( string $ which ) { $ cname = self :: class . '::' . strtoupper ( $ which ) . '_BOM' ; if ( ! defined ( $ cname ) ) return null ; $ bytes = constant ( $ cname ) ; $ bom = '' ; foreach ( $ bytes as $ ord ) $ bom .= chr ( $ ord ) ; return $ bom ; }
Get a BOM for a supported encoding

@param string $which One of UTF8, UTF16LE, UTF16BE, UTF32LE or UTF32BE
@return string The correct BOM
Get a BOM for a supported encoding