Home  >  Article  >  Backend Development  >  Use and development sharing of customized PHP verification code

Use and development sharing of customized PHP verification code

黄舟
黄舟Original
2017-08-15 15:55:03923browse

In the last class, we introduced the use of php verification code style. I believe everyone has a very good understanding of the PHP verification code. The function of the verification code is involved in many places. There are many examples on the Internet, and everyone is familiar with the production of verification codes. First, generate a canvas, and then add strings, straight lines, noise points, and borders to the canvas to generate verification codes. Today I will introduce customized verification codes to you!


Step 1: First download the php verification code class we need for this section: http://www.php .cn/xiazai/leiku/456

Step 2: Then save the downloaded php file library to our local server, and then we create a php file!

The third step: Finally call this class in this new file and instantiate the class:

<?php
include_once "yzm.php"; //引入类文件
$obj = new Authnum();    //实例化 
$obj->ext_num_type=&#39;&#39;;
$obj->ext_pixel = true; //干扰点
$obj->ext_line = false; //干扰线
$obj->ext_rand_y= true; //Y轴随机
$obj->green = 238;      //背景色
$obj->create();         //输出图片
?>

The running result is as shown below:

Use and development sharing of customized PHP verification code

Note:

1. When instantiating an object ($obj = new Authnum()), the parameters after Authnum() are: verification code length, image width, image height, you can fill it in by yourself, you can choose the default!

2.Every time you run or refresh this page, the verification you get is different.

The above is the detailed content of Use and development sharing of customized PHP verification code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn