I have a class with several functions that can render images.
// render.php
class Render {
public function Render($some_arguments) {
...
header("Content-Type: image/png");
$im = @imagecreate(110, 20)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5, "A Simple Text String", $text_color);
imagepng($im);
return "data:image/png;base64,".base64_encode($im);
}
}
Then I have my php file that contains the html code and where I would like to output the image within an < img>
tag:
// index.php
include("render.php");
$render = new Render();
echo "<htlm><head></head><body>";
echo "<img src=\"".$render->Render(1)."\" />";
echo "</body></html>";
When I run index.php in my browser I just get a blank screen.
Can´t I use a function call as an image source? I know I can use a php file as source, like < img src="render_image.php" />
, but then I cannot send any arguments in an object oriented manner (I know I can use $_GET to retrieve arguments), but I would like to do it with a nice object oriented written code.
So, is there any way to use a function call as a source of a html tag?