php把ip生成在图片上
在很多地方我们都会看到把ip地址生成在图片,今天我们就来告诉你如何利用php 把ip生成在图片上,好了下面我们就来看看实例吧,代码如下:
$img = imagecreate(180,50); $ip = $_server['remote_addr']; imagecolortransparent($img,$bgcolor); $bgcolor = imagecolorallocate($img, 0x2c,0x6d,0xaf); // 背景颜色 $shadow = imagecolorallocate($img, 250,0,0); // 阴影颜色 $textcolor = imagecolorallocate($img, oxff,oxff,oxff); // 字体颜色 imagettftext($img,10,0,78,30,$shadow,"c:/windows/fonts/tahoma.ttf",$ip); //显示背景 imagettftext($img,10,0,25,28,$textcolor,"c:/windows/fonts/tahoma.ttf","your ip is".$ip); // 显示ip //开源代码phprm.com imagepng($img); imagecreatefrompng($img); imagedestroy($img);
其实就利用了php生成图片功能,生成验证码也经常会用到这样的功能.
文章网址:http://www.phprm.com/tuxiang/fs4469.html
随意转载^^但请附上教程地址。