Home > Backend Development > PHP Problem > How to convert php string to asc

How to convert php string to asc

藏色散人
Release: 2023-03-10 18:26:02
Original
1833 people have browsed it

How to convert php string to asc: First create a PHP sample file; then convert the characters through "$ch = 'A';$i = ord($ch);var_dump($i);" It can be ASCII code.

How to convert php string to asc

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to convert php string to asc?

PHP - Conversion between ASCII code and characters

ASCII code to character:

<?php
$i = 65;
$ch = chr($i);
var_dump($ch);
?>
string &#39;A&#39; (length=1)
Copy after login

Character to ASCII code:

<?php
$ch = &#39;A&#39;;
$i = ord($ch);
var_dump($i);
?>
Copy after login

int 65

Related introduction:

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

Syntax

ord(string)
Copy after login

Parameters

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

Recommended learning: "PHP Video Tutorial"

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

Related labels:
php
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