国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

ホームページ php教程 php手冊 中國語の英數(shù)字、カスタム フォントの PHP 検証コード コードをサポート

中國語の英數(shù)字、カスタム フォントの PHP 検証コード コードをサポート

Jun 13, 2016 pm 12:02 PM
captcha class php 中國語 コード コピー フォント 手紙 サポート 番號 コード カスタマイズ 確認する

コードをコピー コードは次のとおりです:


/*
* PHP GD Lib ベースの Captcha クラス
* @author Design
* @version 1.0
* @demo
* include('captchaClass.php');
* $captchaDemo=new Captcha();
* $captchaDemo->createImage();
クラス キャプチャ{
// @検証コード畫像の高さを定義します
private $height; //@検証コード畫像の幅を定義します
private $width; //@検証コードの文字數(shù)を定義します
$textNum;
//@検証コードの文字內(nèi)容を定義します
private $textContent; //@文字の色を定義します
//@ランダムなテキストの色を定義します
private $randFontColor;
//@フォント サイズを定義
private $fontSize; ;
//@ランダムな背景色を定義します
private $randBgColor;
//@文字言語を定義します
//@干渉點の數(shù)を定義します
private $noisePoint;
//@干渉ラインの數(shù)を定義します
private $noiseLine;
//@歪ませるかどうかを定義します
private $distortion;畫像ソース
private $distortionImage;
//@境界線があるかどうかを定義します
private $showBorder;
//@検証コード畫像ソースを定義します
private $image;
//@Constructor コンストラクター
public function Captcha(){
$this->gt;textNum=4;
$this->fontFamily; ='c:windowsfontsSIMYOU.ttf'; //中國語フォントを設(shè)定します。Linux ディレクトリに変更できます
$this->textLang='en';
$this->noiseLine=3;
$this->distortion=false;
}


//@畫像の幅を設(shè)定します
public function setWidth($w){
$this->width=$w>

//@畫像の高さを設(shè)定します
public function setHeight($h){
$this->height=$h;
}

//@文字數(shù)を設(shè)定します
public function setTextNumber($textN) ){
$this->textNum=$textN ;
}

//@文字色の設(shè)定
public function setFontColor($fc){
$this-> fontColor=sscanf($fc,'#%2x%2x% 2x');
}

//@フォントサイズを設(shè)定
public function setFontSize($n){
$this->fontSize=$n;
}

//@Set font
public function setFontFamily($ffUrl){
$this->fontFamily=$ffUrl; ??>}

//@文字言語を設(shè)定します
public function setTextLang($lang){
$this->textLang=$lang;
}

/ /@畫像の背景を設(shè)定します
public function setBgColor($bc){
$this->bgColor=sscanf($bc,'#%2x%2x%2x');
}

//@干渉點の數(shù)を設(shè)定します
public function setNoisePoint($ n){
$this->noisePoint=$n;

// @干渉ライン數(shù)を設(shè)定
public function setNoiseLine($n){
$this- >noiseLine=$n>}

//@歪ませるかどうかを設(shè)定 public function setDistortion($b){
$this->distortion=$b;
}

//@ボーダーを表示するかどうかを設(shè)定します
public function setShowBorder($border) ){
$this->showBorder=$border;
}

// @初期化検証コード image
public function initImage(){
if($this ->width)){$this->width=floor($this->fontSize*1.3)*$this->textNum 10;}
if(empty($this->height)) {$this->height=$this->fontSize*2;}
$this->image =imagecreatetruecolor($this->width,$this->height);
if( empty($this->bgColor)){
$this->randBgColor=imagecolorallocate($this->image,mt_rand(100,255),mt_rand(100,255),mt_rand(100,255)); else{
$this->randBgColor=imagecolorallocate($this->image,$this->bgColor [0],$this->bgColor[1],$this->bgColor[2] );
}
imagefill($this->image,0,0,$this->randBgColor);
}

//@ランダムな文字を生成します
function randText($type){
$string='';
switch($type){
case 'en':
$str='ABCDEFGHJKLMNPQRSTUVWXY3456789'; =0;$i<$this->textNum;$i ){
$string=$string.' ,'.$str[mt_rand(0,29)];
}
break;
case 'cn':
for($i=0;$i<$this->textNum ;$i ) {
$string=$string.','.chr(rand(0xB0 ,0xCC)).chr(rand(0xA1,0xBB));
}
$string=iconv( 'GB2312','UTF-8',$string); //エンコーディングを utf8 に変換します。 Break;
}
return substr($string,1);

//@検証コードにテキストを出力
public function createText(){
$textArray =explode(',',$this->randText($this->textLang));
$ this->textContent=join('',$textArray);
if(empty($ this->fontColor)){
$this->randFontColor=imagecolorallocate($this->image, mt_rand(0,100),mt_rand(0,100),mt_rand(0,100));
}else{
$this->randFontColor=imagecolorallocate($this->image,$this->fontColor[0] ,$this->fontColor[1],$this->fontColor[2]); ??>}
for($i=0;$itextNum;$i ){
$angle=mt_rand(-1,1)*mt_rand(1,20);
imagettftext($this->image,$this->fontSize,$angle,5 $i*floor($this->fontSize*1.3),floor($this->height*0.75), $this->randFontColor,$this->fontFamily,$textArray[$i]);
}
}

//@ 生成干擾點
public function createNoisePoint(){
for($i=0;$i<$this->noisePoint;$ i ){
$pointColor=imagecolorallocate($this->image,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imagesetpixel($this->image,mt_rand(0,$this->幅),mt_rand(0,$this->高さ),$pointColor);
}

}

//@產(chǎn)生干擾線
public function createNoiseLine(){
for($i=0;$i<$this->ノイズライン;$i ) {
$lineColor=imagecolorallocate($this->image,mt_rand(0,255),mt_rand(0,255),20);
imageline($this->image,0,mt_rand(0,$this->幅),$this->幅,mt_rand(0,$this->高さ),$lineColor);
}
}

//@扭曲文字
public functiondistortionText(){
$this->distortionImage=imagecreatetruecolor($this->width,$this- >身長);
imagefill($this->distortionImage,0,0,$this->randBgColor);
for($x=0;$xwidth;$x ){
for($y=0;$yheight;$y ){
$rgbColor=imagecolorat($this->image,$x,$y);
imagesetpixel($this->distortionImage,(int)($x sin($y/$this->height*2*M_PI-M_PI*0.5)*3),$y,$rgbColor);
}
}
$this->image=$this->distortionImage;
}

//@生成驗證碼圖片
public function createImage(){
$this->initImage(); //基本的な畫像を作成
$this->createText(); //輸出驗證碼文字
if($this->distortion){$this->distortionText();} //扭曲文字
$this->createNoisePoint(); //産干擾點
$this->createNoiseLine(); //産干擾線
if($this->showBorder){imagerectangle($this->image,0,0,$this->width-1,$this->height-1,$ this->randFontColor);} //追加邊框
imagepng($this->image);
imagedestroy($this->image);
if($this->distortion){imagedestroy($this->$distortionImage);}
return $this->textContent;
}

}
?>使用方法:

//session_start();
header("Content-type:image/png");
include('captcha5_class.php');
$captcha5=新しいキャプチャ();

//@設(shè)置驗證碼寬度
//$captcha5->setWidth(200);

//@設(shè)置驗證碼高さ
//$captcha5->setHeight(50);

//@設(shè)置文字數(shù)
$captcha5->setTextNumber(5);

//@設(shè)置字符顏色
//$captcha5->setFontColor('#ff9900');

//@設(shè)置文字號大小
//$captcha5->setFontSize(25);

//@設(shè)置文字體
$captcha5->setFontFamily('c:windowsfontsSTXINGKA.TTF');

//@設(shè)置語言
$captcha5->setTextLang('cn');

//@設(shè)置背景顏色
//$captcha5->setBgColor('#000000');

//@設(shè)置干擾點數(shù)
//$captcha5->setNoisePoint(600);

//@設(shè)置干擾線數(shù)
//$captcha5->setNoiseLine(10);

//@設(shè)置是否扭曲
//$captcha5->setDistortion(true);

//@設(shè)置かどうか表示邊框
$captcha5->setShowBorder(true);

//出驗證碼
$code=$captcha5->createImage();
//$_SESSION['captchaCode']['content']=$code;
//$_SESSION['captchaCode']['time']=microtime();
?>

このウェブサイトの聲明
この記事の內(nèi)容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰屬します。このサイトは、それに相當する法的責任を負いません。盜作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡(luò)ください。

ホットAIツール

Undress AI Tool

Undress AI Tool

脫衣畫像を無料で

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード寫真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

寫真から衣服を削除するオンライン AI ツール。

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中國語版

SublimeText3 中國語版

中國語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統(tǒng)合開発環(huán)境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

コメントする理由:PHPガイド コメントする理由:PHPガイド Jul 15, 2025 am 02:48 AM

phphastthreecommentStyles://,#forsingle-lineand/.../formulti-line.usecommentstoexplainwhycodeexists、whatittodo/fixmeitemsanddisablecodecodemcodecodecodecodemprianydedebugging.avoidoversingingsingingsingingsingingsingingsingingsingingsimmentingsimmentingsimplelatic.decratecentecentic.

WindowsにPHPをインストールする方法 WindowsにPHPをインストールする方法 Jul 15, 2025 am 02:46 AM

WindowsにPHPをインストールするための重要な手順には次のものがあります。1。適切なPHPバージョンをダウンロードして解凍します。 apacheでthreadsafeバージョンまたはnginxを使用して非threadsafeバージョンを使用することをお勧めします。 2。php.iniファイルを構(gòu)成し、php.ini-developmentまたはphp.ini-productionにphp.iniに名前を変更します。 3.コマンドラインの使用のために、システム環(huán)境変數(shù)パスにPHPパスを追加します。 4. PHPが正常にインストールされているかどうかをテストするには、コマンドラインを介してPHP-Vを?qū)g行し、組み込みサーバーを?qū)g行して解析機能をテストします。 5.Apacheを使用する場合、httpd.confでPを構(gòu)成する必要があります

PHP構(gòu)文:基本 PHP構(gòu)文:基本 Jul 15, 2025 am 02:46 AM

PHPの基本的な構(gòu)文には4つのキーポイントが含まれています。1。PHPタグを終了する必要があり、完全なタグの使用が推奨されます。 2。エコーと印刷は、一般的に出力コンテンツに使用されます。その中には、エコーは複數(shù)のパラメーターをサポートし、より効率的です。 3。注釈方法には、コードの読みやすさを改善するための//、#、//が含まれます。 4.各ステートメントはセミコロンで終了する必要があり、スペースとラインブレークは実行に影響を與えず、読みやすさに影響します。これらの基本的なルールを習得すると、明確で安定したPHPコードの作成に役立ちます。

Python他の例 Python他の例 Jul 15, 2025 am 02:55 AM

PythonのIfelseステートメントを書くための鍵は、論理構(gòu)造と詳細を理解することです。 1.インフラストラクチャは、條件が確立されている場合、コードを?qū)g行することです。 2.多條件判斷はElifで実施され、順次実行され、満たされると停止します。 3。ネストされている場合、さらに區(qū)畫の判斷に使用されている場合、2つの層を超えないことをお勧めします。 4.単純なシナリオでは、単純なifelseを置き換えるために、三元式を使用できます。インデント、條件付き順序、論理的完全性に注意を払うことによってのみ、明確で安定した判斷コードを書くことができます。

PHP 8インストールガイド PHP 8インストールガイド Jul 16, 2025 am 03:41 AM

ubuntuにphp8をインストールする手順は次のとおりです。1。ソフトウェアパッケージリストを更新します。 2。PHP8および基本コンポーネントをインストールします。 3.バージョンを確認して、インストールが成功していることを確認します。 4.必要に応じて追加のモジュールをインストールします。 Windowsユーザーは、ZIPパッケージをダウンロードおよび解凍し、構(gòu)成ファイルを変更し、拡張機能を有効にし、環(huán)境変數(shù)へのパスを追加できます。 MacOSユーザーは、HomeBrewを使用してインストールし、TAPの追加、PHP8のインストール、デフォルトバージョンの設(shè)定、バージョンの検証などの手順を?qū)g行することをお勧めします。インストール方法は異なるシステムで異なりますが、プロセスは明確であるため、目的に応じて適切な方法を選択できます。

PHPとは何ですか?それは何に使用されますか? PHPとは何ですか?それは何に使用されますか? Jul 16, 2025 am 03:45 AM

phpisaserver-sidesscriptinglanguageUsedforwebdevelopment、特にfordynamicwebsitesandcmsplatformslikewordpress.itrunsontheserver、processesdata、interactswithdatabases、andsendshtmltobrowsers.commonusesincludeurauthingication、e-commerceplatoblatoblotoftoflotfontiblotionforthentication

最初のPHPスクリプト:実用的な紹介 最初のPHPスクリプト:実用的な紹介 Jul 16, 2025 am 03:42 AM

最初のPHPスクリプトの書き始め方法は?まず、ローカル開発環(huán)境をセットアップし、XAMPP/MAMP/LAMPをインストールし、テキストエディターを使用してサーバーの実行原則を理解します。第二に、hello.phpというファイルを作成し、基本コードを入力してテストを?qū)g行します。第三に、PHPとHTMLを使用して動的なコンテンツ出力を?qū)g現(xiàn)することを?qū)Wびます。最後に、セミコロンの欠落、引用の問題、ファイル拡張エラーなどの一般的なエラーに注意し、デバッグのエラーレポートを有効にします。

PHPでファイル操作(読書/執(zhí)筆)をどのように処理しますか? PHPでファイル操作(読書/執(zhí)筆)をどのように処理しますか? Jul 16, 2025 am 03:48 AM

tohandlefileoperationsinphp、useappurcefunctionsandmodes.1.toreadafile、usefile_get_contents()forsmallfilesorfgets()inaloop forline-llineprocessing.2.towritetoafile、usefile_put_contents()forsimplewritesorappending withthefile_appendflag、orfwrite()w

See all articles