Jump to content

[SOLVED] OOP Interactive Image


ctechguy

Recommended Posts

I'm starting to learn Object Oriented and trying to make a simple object oriented program that creates an image and applies HTML hotspots on top. I think I need to have a separate page to display the image since it outputs the png header and another with HTML to reference the image. However I want to set all the method variables on one page. Is there a way to pass variables between php scripts. It would be great if someone could point me in the right direction. I'm quite confused. I have successfully create the image.

index.php

<?php
include('class.php');
$us=new drawMe(300,300);?>

 

class.php

<?php
class drawMe{
var $width;
var $height;
var $im;

function __construct($w,$h){
	$this->width=$w;
	$this->height=$h;}
function output(){
	header ("Content-type: image/png");
	$this->im = imagecreate ($this->width, $this->height);
	ImageColorAllocate ($this->im, 0,0,0);
	imagepng($this->im);
      	ImageDestroy ($im);
    }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/171366-solved-oop-interactive-image/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.