Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

iconv_set_encoding

Description

The iconv_set_encoding of iconv for PHP sets the current setting for character encoding conversion.

Syntax

iconv_set_encoding(
    string $type,
    string $encoding
): bool

Parameters

type

The value of type can be any one of these:

Type
input_encoding
output_encoding
internal_encoding

encoding

The character set.

Return

Returns true on success or false on failure.

Examples

1 · type · input_encoding · encoding

<?

$type = "input_encoding";
$encoding = "ISO-8859-1";

iconv_set_encoding($type, $encoding);

$iconv_get_encoding = iconv_get_encoding();

print_r($iconv_get_encoding);

?>
Array
(
    [input_encoding] => ISO-8859-1
    [output_encoding] => UTF-8
    [internal_encoding] => UTF-8
)

2 · type · output_encoding · encoding

<?

$type = "output_encoding";
$encoding = "ISO-8859-1";

iconv_set_encoding($type, $encoding);

$iconv_get_encoding = iconv_get_encoding();

print_r($iconv_get_encoding);

?>
Array
(
    [input_encoding] => UTF-8
    [output_encoding] => ISO-8859-1
    [internal_encoding] => UTF-8
)

3 · type · internal_encoding · encoding

<?

$type = "internal_encoding";
$encoding = "ISO-8859-1";

iconv_set_encoding($type, $encoding);

$iconv_get_encoding = iconv_get_encoding();

print_r($iconv_get_encoding);

?>
Array
(
    [input_encoding] => UTF-8
    [output_encoding] => UTF-8
    [internal_encoding] => ISO-8859-1
)

4 · return

<?

$type = "input_encoding";
$encoding = "ISO-8859-1";

$return = iconv_set_encoding($type, $encoding);

var_export($return);

?>
true
HomeMenu