';" to add the picture ."/> ';" to add the picture .">

Home >Backend Development >PHP Problem >How to add pictures in php

How to add pictures in php

藏色散人
藏色散人Original
2019-11-14 11:34:4914505browse

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;;

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);
?>

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!

Statement:
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