Home > Backend Development > PHP Tutorial > wordpress中输出验证码图片的有关问题

wordpress中输出验证码图片的有关问题

WBOY
Release: 2016-06-13 12:49:39
Original
779 people have browsed it

wordpress中输出验证码图片的问题
要输出的地方是id为209的“页面”

在主题文件夹下的page.php中

<br />
<br />
<?php <br />
<br />
    if(is_page('209')){<br />
        <br />
        header("Content-type: image/gif"); <br />
        header("Cache-Control: no-cache");<br />
<br />
        $rands = rand(1000,9999); <br />
<br />
        $im = imagecreate(40, 15); <br />
        //var_dump($im);exit();<br />
        imagecolorallocate($im, 240, 240, 240); <br />
        $loc = 2; <br />
        $color1=imagecolorallocate($im, 0, 0, 0); <br />
        for($i=0;$i<4;$i++){ <br />
            $color=imagecolorallocate($im, rand(0,255), rand(0,255), rand(0,255)); <br />
            imagestring($im, 4, ($loc+1), 1, substr($rands,$i,1), $color1); <br />
            imagestring($im, 4, $loc, 0, substr($rands,$i,1), $color); <br />
            $loc += 9; <br />
        } <br />
        imagegif($im); <br />
        imagedestroy($im);<br />
<br />
        exit();<br />
    } //验证码<br />
<br />
<br />
?><br />
<br />
Copy after login


该段代码单独文件下正常输出,这里无法正常输出。是wordpress之前的处理过程已经输出了header吗?
我php.ini里有关错误输出的都打开了。。无提示,就是个显示失败的图片

php wordpress
------解决方案--------------------
你是如何调用 page.php 的?
是用 img 标签吗?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template