---
title: "php实例教程：使用php代码实现在网页上生成图片的方法"
author: "naruto1990"
date: "2015-07-20T18:11:42Z"
tags: []
categories: ["Web前端"]
slug: "php-php"
draft: false
lastmod: "2015-07-20T18:12:55Z"
id: 2228843
url: "https://naruto1990.iteye.com/blog/2228843"
---

在php语言的网页中如何使用php代码实现在网页上生成图片呢？今天的php实例教程的主要内容是关于介绍了如何在网页上实现生成图片的简单方法，这是一个非常简单实用的php编程的技巧，感兴趣的朋友可以参考一下，相关的代码会为大家一一列举出来。  
我们可以先看看效果图：  
![使用php代码实现在网页上生成图片的方法](http://www.kokojia.com/Public/images/upload/article/2015-07/55ac68a18c4be.png)  
此次的php学习代码很简单，测试代码如下：  
　　?

1

2

3

4

5

6

7

8

9

10

11

12

 

/\**

\* Created by PhpStorm.

\* User: Administrator

\* Date: 2015/6/29

\* Time: 21:25

\*/

header('Content-type:image/png');//设置mime type

$img = imagecreate(400,300);//设置图片像素

imagecolorallocate($img,255,255,255);//给图片上色

imageellipse($img,200,200,50,50,imagecolorallocate($img,255,0,0));//在图片上绘制图形，中心点200,200；宽高50,50

imagepng($img);//设置图片格式为PNG

  以上就是此次的[php实例教程](http://www.kokojia.com/article/4774.html)的学习，使用php代码就能简单实现在网页上生成图片，希望本文所述的内容对大家的php编程设计有所帮助。