Home > Backend Development > PHP Tutorial > How to display hexadecimal image data on the img tag of html in PHP

How to display hexadecimal image data on the img tag of html in PHP

墨辰丷
Release: 2023-03-27 15:56:02
Original
1696 people have browsed it

The following editor will bring you an article on how to display hexadecimal image data on the img tag of html in PHP (implementation method). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

A production database of SQLServer2008 of the client company has reached a huge size of 18G in just over a year. It turns out that the pictures in the system are directly stored in the database in the form of hexadecimal strings. of. It takes me a lot of time to display it on the html page using PHP.

<?php

// 从数据库读出来的:图片的十六进制形式字符串
$icon_hex = &#39;89504e470d0a1a0a0000000d494844520000001c00000012010300000072c92ca&#39;
    .&#39;700000006504c5445000000ffffffa5d99fdd0000003f49444154089963603e6f60c000266cce1&#39;
    .&#39;b1f8010cc07406220c2febcf10724e2ffe7ff7082f90303e76466062061ccc0603999d90048d81&#39;
    .&#39;b30d809f3400800c0921ea36f9b656d0000000049454e44ae426082&#39;;
$imgdata = base64_encode(pack(&#39;H*&#39;,$icon_hex));
echo &#39;<img src="data:image/png;base64,&#39;. $imgdata .&#39;" />&#39;;

?>
Copy after login

The above is the entire content of this article, I hope it will be helpful to everyone's study.


Related recommendations:

PHP5 Authoritative Programming Reading Study Notes with e-book download_php basics

Introduction to the organizational structure of nginx php-fpm configuration file_php basics

PHPCorrectly parse UTF -8 String Skills Application_php Basics

PHPBasic Knowledge Review_php Basics

The above is the detailed content of How to display hexadecimal image data on the img tag of html in PHP. 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