php製作驗證碼用到的函式

2021-08-21 14:13:40 字數 1483 閱讀 5620

join()函式:把陣列元素組合為乙個字串。

<?php

$number = range(0,5);

print_r ($number);

?>

舉例:

結果:hello world! i love shanghai!

range():range() 函式建立乙個包含指定範圍的元素的陣列。舉例:

<?php

$arr = array('hello','world!','i','love','shanghai!');

echo join(" ",$arr);

?>

結果:array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )

substr():substr() 函式返回字串的一部分。舉例:

<?php

echo substr("hello world",6);

?>

結果:world

str_shuffle()  :函式隨機地打亂字串中的所有字元。

語法 :str_shuffle(string)

strtoupper() 函式把字串轉換為大寫。語法 :strtoupper(string)

imagecreatetruecolor()功能與imagecreate()類似,建立一幅真彩色的影象,從而支援更為豐富的色彩。imagecreatetruecolor( int x, int y )

imagefill() 函式用於影象區域填充。語法 : bool imagefill( resource image, int x, int y, int color )

imagecolorallocate — 為一幅影象分配顏色。語法 : int imagecolorallocate ( resource $image , int $red , int $green , int $blue )

mt_rand() 使用 mersenne twister 演算法返回隨機整數。語法 :mt_rand(min,max)

ceil() 函式向上捨入為最接近的整數。語法 :ceil(x)

imagechar() — 寫出橫向的字元。語法 :bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int $color )

bool imagesetpixel(resource $image,int $x,int $y,int $color)                         //畫乙個單一畫素

bool imageline(resource $image,int $x1,int $y1,int $x2,int $y2,int $color)                //畫一條線段

php 驗證碼製作

直接上 function buildrandomstring type 1,length 4 else if type 2 else if type 3 if length strlen chars 隨意打亂字串 chars str shuffle chars return substr chars...

php製作驗證碼

session start 型別 type gif 的尺寸 width 40 height 16 header content type image type srand double microtime 1000000 生成字元的個數 randval randstr 4,if type gif f...

php製作驗證碼

用php製作乙個一串驗證碼很簡單,主要需要用到一下函式,到手冊上查詢下就知道了,需要注意imagettftext,需要乙個字型檔案,我在win7控制面板字型裡拷貝出來的.這個函式比imagestring 好一點是因為,可以改變字型,和字型大小,imagestring只提供內建的字型大小1,2,3,4...