• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Realm

WordPress news, community news, reviews and more from all over the world

  • News
  • Tutorials
  • About

php

Using PHP Closures in WordPress

14 November 2012 by Joe Hoyle

There has been little discussion on the use of PHP Closures with WordPress code, hopefully we will be able to spark some here! Before getting into the nitty-gritty, to make sure everyone is on the same page a quick explanation of a PHP Closure.

Anonymous functions, also known as closures, allow the creation of functions which have no specified name. They are most useful as the value of callback parameters, but they have many other uses.

php.net

Why Use Closures?

The ability to create single-use callback functions can be very useful when developing in WordPress land, as it’s very often one needs to run code via hooks and filters. At its simplest consider the following code: [Read more…] about Using PHP Closures in WordPress

Filed Under: Practical Tagged With: php

Primary Sidebar

Recent Comments

  • Remkus de Vries on Building a Multilingual Website? These are the Questions to Ask.
  • Tuba on Building a Multilingual Website? These are the Questions to Ask.
  • WPML, qTranslate eller Polylang: hvilken du skal velge og hvorfor? (2020) - My Blog on Building a Multilingual Website? These are the Questions to Ask.
  • Marian Malahin on Building a Multilingual Website? These are the Questions to Ask.
  • WPML,qTranslate X或Polylang – 三种最流行的多语言WordPress插件比较(2019) – wordpress on Building a Multilingual Website? These are the Questions to Ask.
Copyright © 2012 – Today – WP Realm