Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1
Figure 9-8. number_format.

integer ord(string character)


The ord function returns the ASCII code of the first character in the character argument.
This function allows you to deal with characters by their ASCII values, which often can
be more convenient than using backslash codes, especially if you wish to take advantage
of the order of the ASCII table. Refer to Appendix B for a complete table of ASCII
codes.


If you need to find the character associated with an ASCII code, use the chr function.


<?


/*


Decompose a string into its ASCII codes.
Test for codes below 32 because these have
special meaning and we may not want to
print them.
*/


$text = "Line 1\nLine 2\n";


print("ASCII Codes for '$text'
\n");


print("

\n");