Home > Article > Backend Development > Simple implementation method of thinkPHP3.1 verification code, thinkphp3.1 verification code_PHP tutorial
The example in this article describes a simple implementation method of thinkPHP3.1 verification code. Share it with everyone for your reference, the details are as follows:
Write in the code:
public function verify(){ import('ORG.Util.Image'); ob_clean(); Image::buildImageVerify(); }
Write in html:
<img src='__APP__/Index/verify/' onClick="this.src=this.src+'?'+Math.random()" />
That is to say, the path of the image is the access path of the above php code, and it is ok
If the image is not displayed, it is ob_clean(); it is not written. This method is to remove the cache and so on
If it is garbled, just write the above php code directly in front of the display method. Remember, this method is separate and should not be mixed with other methods
Readers who are interested in more thinkPHP-related content can check out the special topics on this site: "ThinkPHP Getting Started Tutorial", "ThinkPHP Common Methods Summary", "Smarty Template Basic Tutorial" and "PHP Template Technology Summary".
I hope this article will be helpful to everyone’s PHP programming based on the ThinkPHP framework.