Heim  >  Artikel  >  Backend-Entwicklung  >  wordpress中输出验证码图片的有关问题

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

WBOY
WBOYOriginal
2016-06-13 12:49:39716Durchsuche

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 />


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

php wordpress
------解决方案--------------------
你是如何调用 page.php 的?
是用 img 标签吗?
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn