↓色と文字とその位置をランダムに変更
↓ソース<?php
$im = imagecreate(10, 10);
imagecolorallocate($im, random_int(0, 127), random_int(0, 127), random_int(50, 127));
$cl = imagecolorallocate($im, random_int(128, 255), random_int(128, 255), random_int(128, 255));
imagechar($im, 5, random_int(0, 2), -3, $a = chr(65 + random_int(0, 25)), $cl);
$imt = imagecreatetruecolor($w=100, $h=100);
imagecopyresampled($imt, $im, 0, 0, 0, 0, 100, 100, 10, 10);
header('Content-type: image/png');
imagepng($imt);
imagedestroy($im);
↓紀永での呼び出し方(記事フォルダに randomA-Z.php を入れた場合)<?php
ob_start();
include 'randomA-Z.php';
$src = ob_get_clean();
?>
<img src="data:image/png;base64,<?=base64_encode($src)?>" alt="<?=$a?>" height="<?=$h?>" width="<?=$w?>">