2014-04-14 35 views
0

下面是PHP代碼,使一個餅圖它保存在一個PHP文件名爲piechart.php使用PHP文件作爲IMG SRC

<?php 

//create image 
$image = imagecreatetruecolor(250,250); 
$white = imagecolorallocate($image, 255, 255, 255); 
imagefill($image, 0, 0, $white); 

//allocate some colour 
$white = imagecolorallocate($image, 0xFF , 0xFF, 0xFF); 
$gray = imagecolorallocate($image, 0xC0 , 0xC0, 0xC0); 
$darkgray = imagecolorallocate($image, 0x90 , 0x90, 0x90); 
$navy = imagecolorallocate($image, 0x00 , 0x00, 0x80); 
$darknavy = imagecolorallocate($image, 0x00 , 0x00, 0x05); 
$red = imagecolorallocate($image, 0xFF , 0x00, 0x00); 
$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00); 

//make the 3d effect 
//for($i = 60; $i >50; $i--){ 
//imagefilledarc($image, 50, $i, 100, 50, 0, 180, $darknavy, IMG_ARC_PIE); 
//imagefilledarc($image, 50, $i, 100, 50, 180, 360, $darkgray, IMG_ARC_PIE); 
//imagefilledarc($image, 50, $i, 100, 50, 180, 360, $darkred, IMG_ARC_PIE); 
//} 
imagefilledarc($image ,125 ,125 , 200, 200, 0, 180, $navy, IMG_ARC_PIE); 
//imagefilledarc($image ,50 ,50 , 100, 50, 180, 360, $gray, IMG_ARC_PIE); 
imagefilledarc($image ,125 ,125 , 200, 200, 180, 360, $red, IMG_ARC_PIE); 

//flush image 
header('Content-type: image/png'); 
imagepng($image); 
//imagedestroy($image); 
?> 

我想在另一個網頁中使用這一形象。我有另一個網頁叫我們解釋什麼是網站。繼承人的代碼,該網頁

<h1>What is Rugby coach analysis ?</h1> 
<hr /> 
<br /> 

一節有沒有一種方法我可以得到這個餅圖形象出現在
下面也許使用IMG SRC?或另一種方法?

謝謝

+2

難道你連嘗試 - 這本來是比郵寄此 – Steve

回答

3

你的意思是這樣的嗎? (piechart.php將是該文件的網址)。

<img src="/piechart.php" alt="pie chart" /> 
+0

找你這麼快......快 – raiserle

+0

@ryan由於不能相信它是如此簡單。 – user3524031