Home > Backend Development > PHP Problem > How to use php bin2hex function

How to use php bin2hex function

青灯夜游
Release: 2023-02-22 18:46:01
Original
3358 people have browsed it

bin2hex() function converts a string of ASCII characters into a hexadecimal value. The syntax is bin2hex(string), which accepts a single parameter string and returns the hexadecimal value of the string passed in the parameter.

How to use php bin2hex function

#How to use php bin2hex() function?

bin2hex() function converts a string of ASCII characters into a hexadecimal value.

Syntax

bin2hex(string)
Copy after login

Parameters:

● string: required. Specifies the string to be converted.

Return value: Returns the hexadecimal value of the string to be converted.

Let’s take a look at how to use the php bin2hex() function through an example.

Example 1:

<?php
$data = "hello php.cn";
$res = bin2hex($data);
echo $res;
?>
Copy after login

Output:

68656c6c6f207068702e636e
Copy after login

Example 2:

<?php
$str1 = "Learning PHP";
echo bin2hex($str1);
?>
Copy after login

Output:

4c6561726e696e6720504850
Copy after login

The above is the detailed content of How to use php bin2hex function. 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