Example 3-3. Using our concatenation function
<?php
function strcat($left, $right) {
return $left . $right;
}
$first = "This is a ";
$second = " complete sentence!";
echo strcat($first, $second);
?>
When this page is displayed, the full sentence is shown.
This function takes in an integer, doubles it, and returns the result:
function doubler($value) {
return $value << 1;
}
Once the function is defined, you can use it anywhere on the page.
For example:
<?= 'A pair of 13s is ' . doubler(13); ?>