From 2a10155772e869b1f5c2d9582f362c74f1598cd3 Mon Sep 17 00:00:00 2001 From: changwei <867597730@qq.com> Date: Thu, 7 Jun 2018 02:38:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E5=9B=BE=E7=89=87=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 这算是一个比较常用的需求了 --- src/helper.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/helper.php b/src/helper.php index 914c749..380e0c4 100644 --- a/src/helper.php +++ b/src/helper.php @@ -50,6 +50,19 @@ function captcha_img($id = '') } +/** + * @param string $id + * @param string $element 验证码HTML元素ID + * @return string + */ +function captcha_img_with_replacement($id = '', $element = 'think-captcha') +{ + return '' . $element .
+        ''; +} + + /** * @param $value * @param string $id From d7dcc6a61505345859a6a123ab2b681a2800fa58 Mon Sep 17 00:00:00 2001 From: changwei <867597730@qq.com> Date: Thu, 7 Jun 2018 02:43:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=A7=84=E8=8C=83readme=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=82=B9=E5=87=BB=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=8D=A2=E9=AA=8C=E8=AF=81=E7=A0=81?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0fced29..1a21be6 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,9 @@ thinkphp5 验证码类库 > composer require topthink/think-captcha -##使用 +## 使用 -###模板里输出验证码 +### 模板里输出验证码 ~~~
{:captcha_img()}
@@ -18,6 +18,11 @@ thinkphp5 验证码类库 ~~~ > 上面两种的最终效果是一样的 +或者带有点击图片自动更换验证码的功能 +~~~ +
{:captcha_img_with_replacement()}
+~~~ + ### 控制器里验证 使用TP5的内置验证功能即可 ~~~