The mysql database stores phone numbers. To avoid spam and customer calls, you need to display these phones on the site in the form of pictures. How can I do that?
- 3There is a great library for working with images - php.net/manual/ru/book.image.php - Yuriy Prokopets
|
1 answer
<?php //height and width of the captch image $width = 180; $height = 30; //phone $phone="+7 (800) 000 0000"; //create the image resource $im = imagecreatetruecolor($width, $height); $bg = imagecolorallocate($im, 230, 80, 0); //background color $fg = imagecolorallocate($im, 255, 255, 255);//text color //fill the image resource with the bg color imagefill($im, 0, 0, $bg); imagestring($im, 5, 10, 8, $phone, $fg);//imagestring //tell the browser that this is an image header("Cache-Control: no-cache, must-revalidate"); header('Content-type: image/png'); //generate the png image imagepng($im); //destroy the image imagedestroy($im); ?> |