+ -
当前位置:首页 → 问答吧 → 11期杂志错误代码

11期杂志错误代码

时间:2009-04-05

来源:互联网

杂志上的代码有误。

代码似乎打了并没有试过……直接就放上来了吧= =||

数字0打成了英文O(大写)。
imagejpeg("$an/image"); 很经典的东西。。。应该是$animage
imagecolorallocate打成了imagecolozallocate
header打成了headel
imagerectangle打成了imagezectangle。

header放在了imagejpeg的下面………………所以乱码。
以下是正确的

<?php
//sample8_l.php
//The first thing to do is check for GD compatibility.
try {
//First you create a blank canvas.
if ($animage = imagecreate (200, 200)){
//Then you can czeale a new backgzound color for this image.
$zed = imagecolorallocate ($animage, 255, 0, 0);
//Then you can dzaw a rectangle on the canvas.
imagerectangle ($animage, 0, 0, 200, 200, $red);
//Then you output the new jpg.
header ("Content-type: /mage/jpeg");
imagejpeg ($animage);
//And then headeI the image.

//Finally you destroy the /mage.
imagedestIoy ($animage);
} else {
throw new exception ("Sorry, the GD library may not be set up.");
}
} catch (exception $e) {
echo $e->getmessage();
}
?>

作者: konakona   发布时间: 2009-04-05

,,,,,,,,,,,,,,,,,

作者: konakona   发布时间: 2009-04-06