PHP bin2hex() 函数

PHP 教程 · 2019-01-29 10:11:28

实例

把 "Hello World!" 转换为十六进制值:

<?php
$str = bin2hex("Hello World!");
echo($str);
?>

定义和用法

bin2hex() 函数把 ASCII 字符的字符串转换为十六进制值。字符串可通过使用 pack() 函数再转换回去。

语法


bin2hex(string)


参数 描述
string 必需。规定要转换的字符串。

技术细节

返回值: 返回要转换字符串的十六进制值。
PHP 版本: 4+

更多实例

实例 1

把一个字符串值从二进制转换为十六进制,再转换回去:

<?php
$str = "Hello world!";
echo bin2hex($str) . "<br>";
echo pack("H*",bin2hex($str)) . "<br>";
?>

点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Concepts, Techniques, and Models of Computer Programming

Concepts, Techniques, and Models of Computer Programming

Peter Van Roy、Seif Haridi / The MIT Press / 2004-2-20 / USD 78.00

This innovative text presents computer programming as a unified discipline in a way that is both practical and scientifically sound. The book focuses on techniques of lasting value and explains them p......一起来看看 《Concepts, Techniques, and Models of Computer Programming》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具