PHP callable Keyword

P
PHP catch Keyword
PHP break Keyword

In this article, you will learn about callable keyword in PHP. The callable keyword in PHP is used to force a function argument to be a reference to a function.

examples of the CALLABLE keyword

Example 1. In this example, we use callable to require a callback function as an argument.

<?php
function printFormatted(callable $format, $str) {
  echo $format($str);
  echo "<br>";
}

function exclaim($str) { return $str . "!"; }
printFormatted("exclaim", "Hello World");
?>
PHP catch Keyword
PHP break Keyword

Tutor Network

Share this

Learn PHP from A to Z