<?php
GdImage|false imagecreate ( int $width , int $height )
where,
$width = The image width in pixels
$height = The image height in pixels
?>
<?php
/*
This exercise does not display any image,
it just displays the identifier: GdImage
This will be displayed using another function
So be patient!
*/
$w01 = 100;
$h01 = 100;
$img01 = imagecreate( $w01, $h01 );
if(PHP_MAJOR_VERSION <= 7)
{
echo PHP_VERSION . '<br>';
echo $img01;
}
else
{
echo PHP_VERSION . '<br>';
var_dump($img01);
}
?>
<?php
/*
This exercise does not display any image,
it just displays the identifier: GdImage
This will be displayed using another function
So be patient!
*/
$w02 = 100;
$h02 = 80;
$img02 = imagecreate( $w02, $h02 );
var_dump($img02);
?>
<?php
/*
This exercise does not display any image,
it just displays the identifier: GdImage
This will be displayed using another function
So be patient!
*/
if (!extension_loaded("gd"))
die("skip GD not present");
if (!function_exists("imagecreate"))
die("skip GD Version not compatible");
function trycatch_dump(...$tests) {
foreach ($tests as $test) {
try {
var_dump($test());
echo '<br><br>';
}
catch (\Error $e) {
echo '!! [' . get_class($e) . '] ' .
$e->getMessage() . "<br><br>";
}
}
}
trycatch_dump(
fn() => imagecreate(10, 10),
fn() => imagecreate(-1, 30),
fn() => imagecreate(30, -1)
);
?>