This paper illustrates the use of CI frame Verification Code captcha auxiliary function, and share it for everyone's reference. Specifically as follows:
Using the Captcha helper function is very convenient to generate the verification code, but the picture is stored in the folder, not the output stream, feel not perfect enough to use.
Description: Generates 4-bit random number, CI root directory to establish Captcha folder.
Copy Code code as follows:
<?php
$this->load->helper (' captcha ');
$vals = Array (
' word ' => rand (1000, 10000),
' Img_path ' => './captcha/',
' Img_url ' => ' http://localhost/ci/captcha/',
' Font_path ' => './path/to/fonts/texb.ttf ',
' Img_width ' => ' 150 ',
' Img_height ' => 30,
' Expiration ' => 7200
);
$cap = Create_captcha ($vals);
echo $cap [' image '];
?>
The results of the operation are shown in the following illustration:
I hope this article will help you with the CI Framework program design.