第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在新的文件中調(diào)用函數(shù)報錯,但在定義函數(shù)的文件中可用

在新的文件中調(diào)用函數(shù)報錯,但在定義函數(shù)的文件中可用

PHP
Kit_G 2017-04-26 01:38:44
如圖,我在image.func.php中輸出getCaptcha();是能夠正常顯示驗證碼的但是,我在新建的getCaptcha.php中調(diào)用image.func.php再使用getCaptcha()的時候卻報錯了,這是為什么??image.func.php中的代碼:<?php ????function?getCaptcha($type?=?3,$length?=?4,$pixel?=?30,$line?=?0){ session_start(); ????//創(chuàng)建底圖 ????$width?=?80; ????$height?=?30; ????$image?=?imagecreatetruecolor($width,?$height); ????$white?=?imagecolorallocate($image,?255,?255,?255); ????$black?=?imagecolorallocate($image,?0,?0,?0); ????//填充畫布 ????//imagefilledrectangle($image,?1,?1,?$width-2,?$height-2,?$white); ????imagefill($image,?0,?0,?$white); ???? ????//獲取驗證碼字段,儲存在session中 ????$type?=?3; ????$length?=?4; ????$chars?=?buildRandomString($type,$length); ????$sess_name?=?"captcha"; ????$_SESSION[$sess_name]?=?$chars; ????$fontfiles?=?array("arial.ttf","ariblk.ttf","simkai.ttf","SIMLI.TTF","simsun.ttc","STLITI.TTF"); ????for?($i=0;?$i?<?$length;?$i++)?{? ???? $fontsize?=?mt_rand(12,18); ???? $angle?=?mt_rand(-15,15); ???? $x?=?($i*15)?+?mt_rand(2,5); ???? $y?=?mt_rand(15,25); ???? $color?=?imagecolorallocate($image,?mt_rand(50,150),?mt_rand(50,150),?mt_rand(50,150)); ???? $font?=?"../fonts/"?.?$fontfiles[mt_rand(0,count($fontfiles)-1)]; ???? $text?=?substr($chars,?$i,?1); ???? imagettftext($image,?$fontsize,?$angle,?$x,?$y,?$color,?$font,?$text); ???? ????} ???? ????//創(chuàng)建干擾元素 ????if($pixel){ ????for?($i=0;?$i?<?$pixel;?$i++)?{? ???? $jamColor?=?imagecolorallocate($image,?mt_rand(100,220),?mt_rand(100,220),?mt_rand(100,220)); ???? imagesetpixel($image,?mt_rand(0,$width-1),?mt_rand(0,$height-1),?$jamColor); ????} } if($line){ for?($i=0;?$i?<?$line;?$i++)?{? $jamColor?=?imagecolorallocate($image,?mt_rand(100,220),?mt_rand(100,220),?mt_rand(100,220)); imageline($image,?mt_rand(0,$width-1),?mt_rand(0,$height-1),?mt_rand(0,$width-1),?mt_rand(0,$height-1),?$jamColor); } } ob_clean(); header('content-type:image/png'); imagepng($image); imagedestroy($image); } getCaptcha();getCaptcha.php的代碼:<?php ????require_once?'lib/image.func.php'; ????getCaptcha();
查看完整描述

3 回答

?
我是新手_請多指教

TA貢獻(xiàn)140條經(jīng)驗 獲得超79個贊

imagettftext中的$font參數(shù)無效,?也就是$font?=?"../fonts/"?.?$fontfiles[mt_rand(0,count($fontfiles)-1)]得到的結(jié)果無效。你新文件中有沒建個文件夾放相對應(yīng)字體的文件"arial.ttf","ariblk.ttf","simkai.ttf","SIMLI.TTF","simsun.ttc","STLITI.TTF"這些

查看完整回答
反對 回復(fù) 2017-04-26
  • Kit_G
    Kit_G
    有啊,我在image.func.php中使用這個函數(shù)是正常的。但是我在getCaptcha.php中required_once 'image.func.php';再使用這個函數(shù),就報錯了。有點搞不懂
  • 3 回答
  • 0 關(guān)注
  • 1339 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號