Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

app_dev's avatar

How Laravel in PHP imagepng convert.

I am developing customized security code. It works on browsers on the computer but does not appear on iphone and android mobile devices. Is there a way to solve this problem?

<?php

//Create a PHP imagepng

session_start();
$scode= substr(md5(rand(0,999999999999)), -6); 
if($scode){
$_SESSION["secode"] = $scode;
$width = 100;
$height = 30;
$img= ImageCreate($width, $height);
$background = ImageColorAllocate($img, 255, 255, 255); 
$rand = ImageColorAllocate($img, rand(0,255), rand(0,255), rand(0,255));
ImageFill($img, 0, 0, $rand);
ImageString($img, 5, 24, 7, $_SESSION["secode"], $background );
ImageLine($img, 0, 19, 0, 19, $arka);
header("Content,type:image/png");
ImagePng($img);
ImageDestroy($img);
}
?>

<!-- --------- HTML ---------------- -->
<img class="d-block mb-2 mx-auto" src="securitycode.php" />
<!-- It works on browsers on the computer but does not appear on iphone and android mobile devices. -->

0 likes
2 replies
Snapey's avatar

ha, good luck with that.

How do you expect the code to be executed when you don't provide a routable URL?

Please or to participate in this conversation.