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.ctype-alpha.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.ctype.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.ctype-alpha.php',
   
1 => 'ctype_alpha',
  ),
 
'up' =>
  array (
   
0 => 'ref.ctype.php',
   
1 => 'Ctype Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.ctype-alnum.php',
   
1 => 'ctype_alnum',
  ),
 
'next' =>
  array (
   
0 => 'function.ctype-cntrl.php',
   
1 => 'ctype_cntrl',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.ctype-alpha" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ctype_alpha</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5)</p><p class="refpurpose"><span class="refname">ctype_alpha</span> &mdash; <span class="dc-title">Check for alphabetic character(s)</span></p>

 </div>

 <a name="function.ctype-alpha.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">bool</span> <span class="methodname"><b>ctype_alpha</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$text</tt></span>
   )</div>

  <p class="para rdfs-comment">
   Checks if all of the characters in the provided string,
   <i><tt class="parameter">text</tt></i>
, are alphabetic.
   In the standard <i>C</i> locale letters are just
   <i>[A-Za-z]</i> and <b>ctype_alpha()</b> is
   equivalent to <i>(ctype_upper($text) || ctype_lower($text))</i>
   if $text is just a single character, but other languages have letters that
   are considered neither upper nor lower case.
  </p>
 </div>


 <a name="function.ctype-alpha.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">text</tt></i>
</span>

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

      <p class="para">
       The tested string.
      </p>
     </dd>

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


 <a name="function.ctype-alpha.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <b><tt class="constant">TRUE</tt></b> if every character in <i><tt class="parameter">text</tt></i>
 is
   a letter from the current locale, <b><tt class="constant">FALSE</tt></b> otherwise.
  </p>
 </div>


 <a name="function.ctype-alpha.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 A <b>ctype_alpha()</b> example (using the default locale)</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$strings&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'KjgWZC'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'arf12'</span><span style="color: #007700">);<br />foreach&nbsp;(</span><span style="color: #0000BB">$strings&nbsp;</span><span style="color: #007700">as&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">ctype_alpha</span><span style="color: #007700">(</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000">&nbsp;consists&nbsp;of&nbsp;all&nbsp;letters.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;</span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000">&nbsp;does&nbsp;not&nbsp;consist&nbsp;of&nbsp;all&nbsp;letters.\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents para"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The string KjgWZC consists of all letters.
The string arf12 does not consist of all letters.
</pre></div>
    </div>
   </div><p>
  </p>
 </div>


 <a name="function.ctype-alpha.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.ctype-upper.php" class="function" rel="rdfs-seeAlso">ctype_upper()</a> - Check for uppercase character(s)</li>
    <li class="member"><a href="function.ctype-lower.php" class="function" rel="rdfs-seeAlso">ctype_lower()</a> - Check for lowercase character(s)</li>
    <li class="member"><a href="function.setlocale.php" class="function" rel="rdfs-seeAlso">setlocale()</a> - Set locale information</li>
   </ul><p>
  </p>
 </div>

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