downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.mb-convert-variables.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.mbstring.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.mb-convert-variables.php',
   
1 => 'mb_convert_variables',
  ),
 
'up' =>
  array (
   
0 => 'ref.mbstring.php',
   
1 => 'Multibyte String Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.mb-convert-kana.php',
   
1 => 'mb_convert_kana',
  ),
 
'next' =>
  array (
   
0 => 'function.mb-decode-mimeheader.php',
   
1 => 'mb_decode_mimeheader',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.mb-convert-variables" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_convert_variables</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">mb_convert_variables</span> &mdash; <span class="dc-title">Convert character code in variable(s)</span></p>

 </div>
  
 <a name="function.mb-convert-variables.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><b>mb_convert_variables</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$to_encoding</tt></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$from_encoding</tt></span>
   , <span class="methodparam"><span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter reference">&amp;$vars</tt></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.php#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter reference">&amp;$...</tt></span>
  ] )</div>

  <p class="para rdfs-comment">
   Converts
   character encoding of variables <i><tt class="parameter">vars</tt></i>
 in
   encoding <i><tt class="parameter">from_encoding</tt></i>
 to encoding
   <i><tt class="parameter">to_encoding</tt></i>
.
  </p>
  <p class="para">
   <b>mb_convert_variables()</b> join strings in Array
   or Object to detect encoding, since encoding detection tends to
   fail for short strings. Therefore, it is impossible to mix
   encoding in single array or object.
  </p>
 </div>

 
 <a name="function.mb-convert-variables.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">to_encoding</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The encoding that the <a href="language.types.string.php" class="type string">string</a> is being converted to.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">from_encoding</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       <i><tt class="parameter">from_encoding</tt></i>
 is specified as an <a href="language.types.array.php" class="type array">array</a>
       or comma separated <a href="language.types.string.php" class="type string">string</a>, it tries to detect encoding from
       <i><tt class="parameter">from-coding</tt></i>
. When <i><tt class="parameter">from_encoding</tt></i>
 
       is omitted, <i>detect_order</i> is used.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">vars</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       <i><tt class="parameter">vars</tt></i>
 is the reference to the
       variable being converted. String, Array and Object are accepted.
       <b>mb_convert_variables()</b> assumes all parameters
       have the same encoding.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">...</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       Additional <i><tt class="parameter">vars</tt></i>
.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>

 
 <a name="function.mb-convert-variables.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The character encoding before conversion for success,
   or <b><tt class="constant">FALSE</tt></b> for failure.
  </p>
 </div>


 <a name="function.mb-convert-variables.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>mb_convert_variables()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*&nbsp;Convert&nbsp;variables&nbsp;$post1,&nbsp;$post2&nbsp;to&nbsp;internal&nbsp;encoding&nbsp;*/<br /></span><span style="color: #0000BB">$interenc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mb_internal_encoding</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$inputenc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">mb_convert_variables</span><span style="color: #007700">(</span><span style="color: #0000BB">$interenc</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"ASCII,UTF-8,SJIS-win"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$post1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$post2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div><p>
  </p>
 </div>


</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites