mb_convert_variables

FunctionParams and return types changed in PHP 8.0

Convert character code in variable(s).

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2-8.3
PHP 8.4
PHP 8.5
PHP 8.6

mb_convert_variables Function synopsis

mb_convert_variables(
    string $to_encoding,
    array|string $from_encoding,
    mixed &$var,
    mixed ...&$vars
  ): string|false

Parameters

$to_encoding

Typestring

The encoding that the string is being converted to.

$from_encoding

Typearray|string

$from_encoding is specified as an array or comma separated string, it tries to detect encoding from $from_coding. When $from_encoding is omitted, detect_order is used.

$var

Passed by referenceTypemixed

$var is the reference to the variable being converted. String, Array and Object are accepted. mb_convert_variables assumes all parameters have the same encoding.

$vars

Variadic, Passed by reference, OptionalTypemixed

Additional $vars.

Note that the parameters $var and $vars are passed by reference, and contain additional/updated context data that may be useful.

Return value

Typestring|false

The character encoding before conversion for success, or false for failure.

Changes to the mb_convert_variables Function

PHP 8.0

  • Return type added: string|false
  • Optional parameter added - #4: mixed &$vars
 mb_convert_variables(
-    $to,
-    $from,
-    ...&$vars
-  )
+    string $to_encoding,
+    array|string $from_encoding,
+    mixed &$var,
+    mixed ...&$vars
+  ): string|false

PHP 5.6

  • Parameter name of parameter #3 changed: $... to $vars
  mb_convert_variables(
      $to,
      $from,
-     &$...
+     ...&$vars
    )

mb_convert_variables Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes