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 '<img src='1.gir' width="100" height="100">';
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, 'Hello,PHP', $white); //输出图像,定义头 Header ('Content-type: image/png'); //将图像发送至浏览器 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!