PHP callable Keyword

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

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top