为什么我的班级不画画?如果我让它成为它运行的唯一函数,但在类中它不起作用:(。我是 PHP 类的新手(Java 类对我来说不是新的)。
<?php
class Schild
{
public function __construct(){
$text = $_GET['text'];
$picture = imagecreatefrompng("bild.png");
$pika = imagecreatefromjpeg("pika.jpg");
$pika_size = getimagesize("pika.jpg");
}
public function drawPicture()
{
$im = imagecolorallocate ($picture, 255, 0, 255);
imagettftext($picture, 111, 0, 100, 100,$im , "Marmellata(Jam)_demo.ttf", $text);
# int ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
imagecopy($picture, $pika, 50, 50, 0, 0, $pika_size[0], $pika_size[1]);
$zufall = rand(1,99999999);
#header("Content-Type: image/jpeg");
imagejpeg($picture);
imagedestroy($picture);
}
}
$schild1 = new Schild();
$schild1->drawPicture();
?>