• 技术文章 >后端开发 >php教程

    php将数据库中的电话号码读取出来并生成图片_PHP

    2016-06-01 12:24:53原创378
    以下是代码:
    复制代码 代码如下:
    $id=$_GET[id];
    include("admin/config.php");
    $sql="select * from user where id=$id";
    $data=mysql_fetch_array(mysql_query($sql));
    $p=SBC_DBC($data[Phone],1);
    function get_str($str,$strlen=16) {
    $str=stripslashes($str);
    for($i=0;$i<$strlen;$i++)
    if(ord(substr($str,$i,1))>0xa0) $j++;
    if($j%2!=0) $strlen++;
    $tmp_str=substr($str,0,$strlen);
    return $tmp_str;
    }
    if($p<>''){
    //生成5位的数字图片
    Header("Content-type:image/png"); //告诉浏览器,下面的数据是图片,而不要按文字显示

    //定义图片宽高
    $nwidth=120;
    $nheight=25;
    $im=@imagecreate($nwidth,$nheight) or die("Can't initialize new GD image stream"); //建立图象

    //图片色彩设置
    $background_color=imagecolorallocate($im,255,255,255); //匹配颜色
    $text_color=imagecolorallocate($im,23,14,91);

    //绘制图片边框
    imagefilledrectangle($im,0,0,$nwidth-1,$nheight-1,$background); //矩形区域着色
    imagerectangle($im,0,0,$nwidth-1,$nheight-1,$background_color); //绘制矩形

    //srand((double)microtime()*1000000); //取得目前时间的百万分之一秒值,以执行时的百万分之一秒当乱数种子
    //$randval=rand();
    $randval=$p; //5位数
    imagestring($im,8,10,2,$randval,$text_color); //绘制横式字串


    //加入干扰因素
    //for($i=0;$i<478;$i++)
    //{
    //$randcolor=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));
    //imagesetpixel($im,rand()%100,rand()%30,$randcolor); //点
    /
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:php 电话号码 图片
    上一篇:php下删除字符串中HTML标签的函数_PHP 下一篇:PHP通用分页类page.php[仿google分页]_PHP
    VIP课程(WEB全栈开发)

    相关文章推荐

    • 【腾讯云】年中优惠,「专享618元」优惠券!• PHP是如何存储变量的?zval结构体你了解吗?• Yii快速入门经典教程_php实例• ThinkPHP单字母函数(快捷方法)使用总结_php实例• ThinkPHP2.0读取MSSQL提示Incorrect syntax near the keyword 'AS'的解决方法_php实例• php实现水仙花数的4个示例分享_php实例
    1/1

    PHP中文网