Home > Backend Development > PHP Problem > How to convert php characters to ASCII code

How to convert php characters to ASCII code

藏色散人
Release: 2023-03-01 07:06:01
Original
3931 people have browsed it

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)
Copy after login

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>";
?>
Copy after login

Run result:

104
104
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template