Current Location: Home> Function Categories> ord

ord

Convert the first byte of the string to a value between 0-255
Name:ord
Category:String
Programming Language:php
One-line Description:Returns the ASCII value of the first character in the string.

Example

Returns the ASCII value of "S":

 <span class="token php language-php"><span class="token delimiter important"><?php</span>
<span class="token keyword">echo</span> <span class="token function">ord</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"S"</span> <span class="token punctuation">)</span> <span class="token operator">.</span> <span class="token string double-quoted-string">"<br>"</span> <span class="token punctuation">;</span>
<span class="token keyword">echo</span> <span class="token function">ord</span> <span class="token punctuation">(</span> <span class="token string double-quoted-string">"Shanghai"</span> <span class="token punctuation">)</span> <span class="token operator">.</span> <span class="token string double-quoted-string">"<br>"</span> <span class="token punctuation">;</span>
<span class="token delimiter important">?></span></span>

Try it yourself

Similar Functions
  • Output one or more strings echo

    echo

    Outputoneormorestrin
  • Calculate the soundex key of a string soundex

    soundex

    Calculatethesoundexk
  • Output formatted string printf

    printf

    Outputformattedstrin
  • Inversely escape an escaped string stripslashes

    stripslashes

    Inverselyescapeanesc
  • Calculate the length of the first substring in which all characters in the string exist in the specified character set strspn

    strspn

    Calculatethelengthof
  • Convert all applicable characters to HTML entities - Convert characters to HTML escape characters htmlentities

    htmlentities

    Convertallapplicable
  • Remove spaces (or other characters) from the beginning and end of the string trim

    trim

    Removespaces(orother
  • Use one string to split another string into an array explode

    explode

    Useonestringtosplita