<span><span><span class="hljs-meta"><?php</span></span><span>
</span><span><span class="hljs-comment">// This is an unrelated PHP code example</span></span><span>
</span><span><span class="hljs-keyword">echo</span></span><span> </span><span><span class="hljs-string">"This is a sample program demonstrating PHP code structure."</span></span><span>;
</span><span><span class="hljs-meta">?></span></span><span>
<p><hr></p>
<p></span><?php<br>
/*</p>
<ul>
<li>
<p>Article Title: How to Use the ord() Function in PHP to Determine if a Character is Uppercase or Lowercase</p>
</li>
<li></li>
<li>
<p>The ord() function returns the ASCII value of a character.</p>
</li>
<li>
<p>In the ASCII table, uppercase letters A-Z range from 65 to 90,</p>
</li>
<li>
<p>and lowercase letters a-z range from 97 to 122.</p>
</li>
<li>
<p>By using ord() to get a character's ASCII code,</p>
</li>
<li>
<p>you can determine whether it is uppercase or lowercase by comparing the value.<br>
*/</p>
</li>
</ul>
<p>function checkCase($char) {<br>
$ascii = ord($char);<br>
if ($ascii >= 65 && $ascii <= 90) {<br>
return "Uppercase letter";<br>
} elseif ($ascii >= 97 && $ascii <= 122) {<br>
return "Lowercase letter";<br>
} else {<br>
return "Not an English letter";<br>
}<br>
}</p>
<p>// Test examples<br>
$testChars = ['A', 'z', 'M', 'm', '9', '@'];</p>
<p>foreach ($testChars as $c) {<br>
echo "Character '{$c}' is: " . checkCase($c) . "<br>";<br>
}</p>
<p>/*<br>
Output:<br>
Character 'A' is: Uppercase letter<br>
Character 'z' is: Lowercase letter<br>
Character 'M' is: Uppercase letter<br>
Character 'm' is: Lowercase letter<br>
Character '9' is: Not an English letter<br>
Character '@' is: Not an English letter<br>
*/</p>
<p data-is-last-node="" data-is-only-node="">/*<br>
Summary:<br>
The ord() function is very useful for determining character types, especially for checking the case of English letters.<br>
Simply retrieve the ASCII code of a character and compare it with the relevant range.<br>
*/<br>
?><br>