php 如何对简单过滤器使用匿名函数 Posted 2021-05-04 tags: 篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 如何对简单过滤器使用匿名函数相关的知识,希望对你有一定的参考价值。 <?php /** * This gist is example code that goes with an article on how (and why/when) to use * PHP anonymous functions. To view the entire post, go to: * https://rocketgeek.com/basics/using-anonymous-functions-for-filters-and-actions/ */ add_filter( 'name_of_hook', 'name_of_function_to_use' ); function name_of_function_called( $some_argument ) { // do something... return $something; } add_filter( 'excerpt_length', 'excerpt_length_example' ); function excerpt_length_example( $words ) { return 15; } add_filter( 'excerpt_length', function( $words ) { return 15; }); 以上是关于php 如何对简单过滤器使用匿名函数的主要内容,如果未能解决你的问题,请参考以下文章