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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

Can't use function return value in write context

<?php?


class Captcha{

//字體文件

private $_fontfile='';

//字體大小

private $_size =20;

//畫布寬度

private $_width = 120;

//畫布高度

private $_height = 40;

//驗證碼長度

private $_length = 4;

//畫布資源

private $_image =null;

//干擾元素

//雪花的個數(shù)

private $_snow=0;

//像素點個數(shù)

private $_pixel=0;

//線段個數(shù)

private $_line=0;

/**

* 初始化數(shù)據(jù)

* @param array $config [description]

*/

public function __construct($config=array()){

if(is_array($config)&&count($config)>0){

/**

* 檢測字體文件是否存在并且可讀

*/

if(isset($config['fontfile'])&&is_file($config['fontfile'])&&is_readable($config['fontfile'])){

$this->_fontfile=$config['fontfile'];

}

//檢測畫布高度和寬度

if(isset($config('width'))&&$config['width']>0){

$this->_width=(int)$config['width'];

}

if(isset($config('height'))&&$config['height']>0){

$this->_height=(int)$config['height'];

}

//檢測字符大小

if(isset($config('size'))&&$config['size']>0){

$this->_size=(int)$config['size'];

}

//檢測驗證碼長度

if(isset($config('length'))&&$config['length']>0){

$this->_length=(int)$config['length'];

}

//配置干擾元素

if(isset($config('snow'))&&$config['snow']>0){

$this->_snow=(int)$config['snow'];

}

if(isset($config('pixel'))&&$config['pixel']>0){

$this->_pixel=(int)$config['pixel'];

}

if(isset($config('line'))&&$config['line']>0){

$this->_line=(int)$config['line'];

}

$this->_image=imagecreatetruecolor($this->_width, $this->_height);

return $this->_image;

}else{

return flase;

}


}




/**

* 得到驗證碼

* @return [type] [description]

*/

public function getCaptcha(){

$white = imagecolorallocate($this->_image, 255, 255, 255);

//填充矩形

imagefilledrectangle($this->_image,0,0,$this->_width,$this->_height,$white);

//生成驗證碼

$str=$this->_generateStr($this->_length);

if(false==$str){

return false;

}

//繪制驗證碼

$fontfile=$this->_fontfile;

for($i=0;$i<$this->$_length;$i++){

$size=$this->_size;

$angle=mt_rand(-15,15);

$x=ceil($this->_width/$this->_height)*$i+mt_rand(5,10);

$y=ceil($this->_height/1.5);

$color=$this->_getRandColor();

$text=$str{$i};

imagettftext($this->_image,$size,$angle,$x,$y,$color,$fontfile,$text);

}

//繪制干擾元素

if ($this->_snow) {

$this->_getSnow();

# code...

}else{

if($this->_pixel){

$this->_getPixel();

}

if($this->_line){

$this->_getLine();

}

}

//繪制圖像

header('content-type:image/png');

imagepng($this->_image);

imagedestroy($this->_image);

return strtolower($str);

}

/**

* 生成雪花

* @return [type] [description]

*/

private function _getSnow(){

for($i=1;$i<=$this->_snow;$i++){

imagestring($this->_image,mt_rand(1,5),mt_rand(0,$this->_width),mt_rand(0,$this->_height),'*',$this->_getRandColor());

}

}

/**

* 生成像素點

* @return [type] [description]

*/

private function _getPixel(){

for($i=1;$i<=$this->_pixel;$i++){

imagesetpixel($this->_image,mt_rand(0,$this->_width),mt_rand(0,$this->_height),$this->_getRandColor());

}

}

/**

* 生成線條

* @return [type] [description]

*/

private function _getLine(){

for($i=1;$i<=$this->_line;$i++){

imageline($this->ima, mt_rand(0,$this->_width),mt_rand(0,$this->$height), mt_rand(0,$this->_width), mt_rand(0,$this->_height),$this->_getRandColor());

}

}






/**

* 產(chǎn)生驗證碼字符

* @param ?integer $length 驗證碼長度

* @return [type] ? ? ? ? ?隨機(jī)字符

*/

public function _generateStr($length=4){

if($length<1||$length>30){

return false;

}

$chars = array(

'a','b','c','d','e','f','g','h','k','m','n','p','x','y','z','A','B','C','D','E','F','G','H','K','M','N','P','X','Y','Z',1,2,3,4,5,6,7,8,9

);

$str = join('',array_rand(array_flip($chars),$length));

}


private function _getRandColor(){

return imagecolorallocate($this->_image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));

}







}

報錯;?Can't use function return value in write context in D:\pycharm\Demo\Capcha.class.php on line?36

這個怎么解決求證

正在回答

1 回答

if(isset($config('width'))&&$config['width']>0){?? 是方括號,不是小括號,后面幾行都是。

還有構(gòu)造函數(shù)最后的應(yīng)該是 return false ,不是flase。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕斯卡1548473 提問者

非常感謝!
2017-12-20 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
PHP進(jìn)階篇-GD庫圖像處理
  • 參與學(xué)習(xí)       10436    人
  • 解答問題       72    個

想通過PHP中GD函數(shù)庫靈活操作圖像嗎,點擊學(xué)習(xí)本教程可以實現(xiàn)

進(jìn)入課程

Can't use function return value in write context

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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