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

Anew_G 2013-04-01 11:53:33
要输出的地方是id为209的“页面”

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



<?php

if(is_page('209')){

header("Content-type: image/gif");
header("Cache-Control: no-cache");

$rands = rand(1000,9999);

$im = imagecreate(40, 15);
//var_dump($im);exit();
imagecolorallocate($im, 240, 240, 240);
$loc = 2;
$color1=imagecolorallocate($im, 0, 0, 0);
for($i=0;$i<4;$i++){
$color=imagecolorallocate($im, rand(0,255), rand(0,255), rand(0,255));
imagestring($im, 4, ($loc+1), 1, substr($rands,$i,1), $color1);
imagestring($im, 4, $loc, 0, substr($rands,$i,1), $color);
$loc += 9;
}
imagegif($im);
imagedestroy($im);

exit();
} //验证码


?>



该段代码单独文件下正常输出,这里无法正常输出。是wordpress之前的处理过程已经输出了header吗?
我php.ini里有关错误输出的都打开了。。无提示,就是个显示失败的图片
...全文
192 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Anew_G 2013-04-01
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
你是如何调用 page.php 的? 是用 img 标签吗?
我现在直接输出都输不出来 http://localhost:8889/验证码/
xuzuning 2013-04-01
  • 打赏
  • 举报
回复
你是如何调用 page.php 的? 是用 img 标签吗?

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧