About the use of thinkphp behavior

不言
Release: 2023-04-02 19:54:01
Original
1387 people have browsed it

这篇文章主要介绍了关于thinkphp行为的使用,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下

行为说简单一点就是程序执行到某一步会自动调用的一段操作,示例如下

第一步、添加行为标签位

$param['ids'] = $ids;
Hook::listen('event_reject',$param);
Copy after login

参数$param可选

第二步、行为绑定

在项目目录APP_PATH下的tags.php文件中进行绑定

return [    'event_stop_publish'=>['app\\qikan\\behavior\\StopPublish']];
Copy after login

第三步、在绑定的行为位置进行行为定义

namespace app\index\behavior;class Test 
{    public function app_init(&$param)
    {        //$params 为引用传递    }    
    public function app_end(&$param)
    {

    }    
}
Copy after login

 以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

相关推荐:

WordPress 之在注册界面 实现 注册后密码直接显示在页面上

php压缩解压缩文件的代码

The above is the detailed content of About the use of thinkphp behavior. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!