<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Return a specific character</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.chop.html">chop</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.chunk-split.html">chunk_split</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.chr" class="refentry"> <div class="refnamediv"> <h1 class="refname">chr</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">chr</span> — <span class="dc-title">Return a specific character</span></p> </div> <div class="refsect1 description" id="refsect1-function.chr-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>chr</strong></span> ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$ascii</code></span> )</div> <p class="para rdfs-comment"> Returns a one-character string containing the character specified by <em><code class="parameter">ascii</code></em>. </p> <p class="para"> This function complements <span class="function"><a href="function.ord.html" class="function">ord()</a></span>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.chr-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">ascii</code></em></span> <dd> <p class="para"> The ascii code. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.chr-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the specified character. </p> </div> <div class="refsect1 examples" id="refsect1-function.chr-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-4818"> <p><strong>Example #1 <span class="function"><strong>chr()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">"The string ends in escape: "</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">.= </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">27</span><span style="color: #007700">); </span><span style="color: #FF8000">/* add an escape character at the end of $str */<br /><br />/* Often this is more useful */<br /><br /></span><span style="color: #0000BB">$str </span><span style="color: #007700">= </span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The string ends in escape: %c"</span><span style="color: #007700">, </span><span style="color: #0000BB">27</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.chr-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.sprintf.html" class="function" rel="rdfs-seeAlso">sprintf()</a> - Return a formatted string</span> with a format string of <em>%c</em></li> <li class="member"> <span class="function"><a href="function.ord.html" class="function">ord()</a></span></li> <li class="member">An <a href="http://www.asciitable.com" class="link external">» ASCII-table</a></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.chop.html">chop</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.chunk-split.html">chunk_split</a></div> <div class="up"><a href="ref.strings.html">String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>