Home > Article > Backend Development > How to display IP address in pictures in php_PHP tutorial
PHP code:
$img = ImageCreate(180,50);
$ip = $_SERVER[REMOTE_ADDR];
ImageColorTransparent($img,$bgcolor);
$bgColor = ImageColorAllocate($img, 0x2c,0x6D,0xAF); // Background color
$shadow = ImageColorAllocate($img, 250,0,0); // Shadow color
$textColor = ImageColorAllocate($img, oxff,oxff,oxff); // Font color
ImageTTFText($img,10,0,78,30,$shadow,"c:/windows/fonts/Tahoma.ttf",$ip);
//Show background
ImageTTFText($img,10,0,25,28,$textColor,"c:/windows/fonts/Tahoma.ttf","your ip is".$ip);
//Display IP
ImagePng($img);
imagecreatefrompng($img);
ImageDestroy($img);
?>