What is meant by the term “hook” in programming?

前端 未结 12 2463
暖寄归人
暖寄归人 2020-12-07 06:56

I recently heard the term \"hook\" while talking to some people about a program I was writing. I\'m unsure exactly what this term implies although I inferred from the conve

12条回答
  •  眼角桃花
    2020-12-07 07:19

    In the Drupal content management system, 'hook' has a relatively specific meaning. When an internal event occurs (like content creation or user login, for example), modules can respond to the event by implementing a special "hook" function. This is done via naming convention -- [your-plugin-name]_user_login() for the User Login event, for example.

    Because of this convention, the underlying events are referred to as "hooks" and appear with names like "hook_user_login" and "hook_user_authenticate()" in Drupal's API documentation.

提交回复
热议问题