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

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

中國語の英數字、カスタム フォントの 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; //@検証コードの文字數を定義します
$textNum;
//@検証コードの文字內容を定義します
private $textContent; //@文字の色を定義します
//@ランダムなテキストの色を定義します
private $randFontColor;
//@フォント サイズを定義
private $fontSize; ;
//@ランダムな背景色を定義します
private $randBgColor;
//@文字言語を定義します
//@干渉點の數を定義します
private $noisePoint;
//@干渉ラインの數を定義します
private $noiseLine;
//@歪ませるかどうかを定義します
private $distortion;畫像ソース
private $distortionImage;
//@境界線があるかどうかを定義します
private $showBorder;
//@検証コード畫像ソースを定義します
private $image;
//@Constructor コンストラクター
public function Captcha(){
$this->gt;textNum=4;
$this->fontFamily; ='c:windowsfontsSIMYOU.ttf'; //中國語フォントを設定します。Linux ディレクトリに変更できます
$this->textLang='en';
$this->noiseLine=3;
$this->distortion=false;
}


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

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

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

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

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

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

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

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

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

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

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

//@ボーダーを表示するかどうかを設定します
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);
}

}

//@產生干擾線
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=新しいキャプチャ();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ホット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開発とベストプラクティスを最新の狀態(tài)に保つにはどうすればよいですか? 最新のPHP開発とベストプラクティスを最新の狀態(tài)に保つにはどうすればよいですか? Jun 23, 2025 am 12:56 AM

postaycurrentwithpdevellyments andbest practices、follow keynewsourceslikephp.netandphpweekly、egagewithcommunitiessonforums andconferences、keeptooling and gradivallyadoptnewfeatures、andreadorcontributeTopensourceprijeprijeprijeptrijeprijeprests.

PHPとは何ですか、そしてなぜそれがWeb開発に使用されるのですか? PHPとは何ですか、そしてなぜそれがWeb開発に使用されるのですか? Jun 23, 2025 am 12:55 AM

PhpBecamepopularforwebdevelopmentduetoitseaseaseaseaseasease、SeamlessintegrationWithhtml、widespreadhostingsupport、andalargeecosystemincludingframeworkelavelandcmsplatformslikewordspresspressinsinsionsisionsisionsisionsisionsionsionsisionsionsionsisionsisions

PHPタイムゾーンを設定する方法は? PHPタイムゾーンを設定する方法は? Jun 25, 2025 am 01:00 AM

tosettherighttimezoneInphp、usedate_default_timezone_set()functionthestthestofyourscriptwithavalididentifiersiersuchas'america/new_york'.1.usedate_default_timezone_set()beforeanydate/timefunctions.2.2.Altertentally、confuturethephp.inifilebyset.

クリーンで保守可能なPHPコードを書くためのベストプラクティスは何ですか? クリーンで保守可能なPHPコードを書くためのベストプラクティスは何ですか? Jun 24, 2025 am 12:53 AM

清潔で維持しやすいPHPコードを書くための鍵は、標準、合理的な構造に従って、コメント、テスト能力を適切に利用する明確な命名にあります。 1。$ userDataやcalculatetotalprice()などの明確な変數、関數、クラス名を使用します。 2。PSR-12標準統(tǒng)一コードスタイルに従ってください。 3.責任に従ってコード構造を分割し、MVCまたはLaravelスタイルのカタログを使用して整理します。 4.麺スタイルのコードを避け、単一の責任でロジックを小さな関數に分割します。 5.キーポイントにコメントを追加し、インターフェイスドキュメントを書き込み、パラメーター、返品値、例外を明確にします。 6.テスト可能性を改善し、依存関係を採用し、グローバルな狀態(tài)と靜的な方法を減らします。これらのプラクティスは、コードの品質、コラボレーション効率、メンテナンス後の容易さを改善します。

PHPでページキャッシュを使用するにはどうすればよいですか? PHPでページキャッシュを使用するにはどうすればよいですか? Jun 24, 2025 am 12:50 AM

PHPページのキャッシュは、サーバーの負荷を削減し、ページの読み込みをスピードアップすることにより、ウェブサイトのパフォーマンスを改善します。 1.基本ファイルキャッシュは、靜的HTMLファイルを生成し、有効期間中にサービスを提供することにより、動的コンテンツの繰り返し生成を回避します。 2. OpCacheがPHPスクリプトをBytecodeにコンパイルし、メモリに保存できるようにし、実行効率を向上させます。 3。パラメーターを備えた動的ページの場合、それらはURLパラメーターに従って個別にキャッシュする必要があり、キャッシュされたユーザー固有のコンテンツを避けます。 4. PHPFastCacheなどの軽量キャッシュライブラリを使用して、開発を簡素化し、複數のストレージドライバーをサポートできます。これらの方法を組み合わせることで、PHPプロジェクトのキャッシュ戦略を効果的に最適化できます。

PHPコードスニペットをすばやくテストする方法は? PHPコードスニペットをすばやくテストする方法は? Jun 25, 2025 am 12:58 AM

toquicklyteStaphpcodesnippet、useanonlinephpsandboxlike3v4l.orgorphpize.onlineforinstantexecutionwithoututup; runco??delocally withphpclibycreatinga.phpfileandexecutedecutediTviatherminal;

PHP(&&、||、!、および、または、xor)で論理演算子を使用するにはどうすればよいですか? PHP(&&、||、!、および、または、xor)で論理演算子を使用するにはどうすればよいですか? Jun 23, 2025 am 12:56 AM

PHPでは、論理演算子が條件を組み合わせたり評価したりするために使用され、主な演算子には&&、||、または!、およびXorが含まれます。 1。&&と優(yōu)先事項の違い。 &&は割り當てオペレーターよりも高く、割り當て演算子よりも低いため、割り當てを組み合わせると動作が異なります。 2. ||また、同様の優(yōu)先度の違いがあります||割り當てよりも優(yōu)先されますが、割り當て後に処理されます。 3.!オペレーターは、ブール値を反転するために使用され、條件が間違っているかどうかを確認するためによく使用されます。また、正しいアプリケーションを確保するために複雑な式をブラケットに包むことをお勧めします。 4.XORは、2つの値のうち正確な値が真である場合にのみTRUEを返します。

See all articles