[php]利用php輸出客戶端ip
發表於 : 2008年 11月 27日, 11:16
直接利用 GD 的功能, 建立一張 png 圖後, 利用 imagestring 輸出 $_server["remote"addr"] 即可, 程式碼如下,
代碼: 選擇全部
<?php
header("Content-type: image/png");
$im = @imagecreate(180, 50)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 5, 5, 5, "ip:".$_SERVER["REMOTE_ADDR"], $text_color);
imagepng($im);
imagedestroy($im);
?>