Home> PHP Framework> ThinkPHP> body text

How to use thinkphp behavior

藏色散人
Release: 2021-05-28 08:52:54
forward
2038 people have browsed it

下面由thinkphp框架教程栏目给大家介绍thinkphp行为如何使用,希望对需要的朋友有所帮助!

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

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

Related labels:
source:cnblogs.com
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
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!