How to add pictures in php

藏色散人
Release: 2023-02-28 14:28:01
Original
14495 people have browsed it

How to add pictures in php

How to add pictures in php? What is the code to insert pictures in php?

PHP inserts pictures, but actually outputs HTML code

For example:

echo &#39;<img src=&#39;1.gir&#39; width="100" height="100">&#39;;
Copy after login

You can also directly use PHP to generate pictures and display them

php The gd library can generate a variety of image files, such as gif, png, jpg, wbmp, xpm, etc. Let's look at a file that generates a square.

<?php
$height = 300;
$width = 300;
//创建背景图
$im = ImageCreateTrueColor($width, $height);
//分配颜色
$white = ImageColorAllocate ($im, 255, 255, 255);
$blue = ImageColorAllocate ($im, 0, 0, 64);
//绘制颜色至图像中
ImageFill($im, 0, 0, $blue);
//绘制字符串:Hello,PHP
ImageString($im, 10, 100, 120, &#39;Hello,PHP&#39;, $white);
//输出图像,定义头
Header (&#39;Content-type: image/png&#39;);
//将图像发送至浏览器
ImagePng($im);
//清除资源
ImageDestroy($im);
?>
Copy after login

Recommended: "PHP Tutorial"

The above is the detailed content of How to add pictures in php. 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