PHP Functional Programming, helper function, annonymous function, closure

 
<?php
$url = function($folder) use ($hostname) {
return $hostname . DIRECTORY_SEPARATOR . $folder;
};
 
$hostname = "https://" . $_SERVER['SERVER_NAME'];
 
$myurl = $url('pictures');
echo $myurl;
 
// output
// https://www.aghayev.com/pictures

Leave a Reply