Home  >  Article  >  Backend Development  >  How to convert php characters to ASCII code

How to convert php characters to ASCII code

藏色散人
藏色散人Original
2020-05-10 11:47:353917browse

How to convert php characters to ASCII code

How to convert characters to ASCII code in php

In PHP, you can use the ord() function to convert characters is ASCII code.

ord() Definition and Usage

ord() function returns the ASCII value of the first character in the string.

Syntax

ord(string)

Parameters

string Required. The string from which to obtain the ASCII value.

Return value: Returns the ASCII value in integer form.

Example

Return the ASCII value of "h":

<?php
echo ord("h")."<br>";
echo ord("hello")."<br>";
?>

Run result:

104
104

Recommendation: " PHP video tutorial

The above is the detailed content of How to convert php characters to ASCII code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn