Alternate Switch with PHP
<?php
function alternate_switch($condition, $cases)
{
return $cases[$condition]();
}
$siteStatus = 'offline'; // Probably gotten from config or whatever!!
alternate_switch($siteStatus, [
'offline' => function () {
echo 'Site is offline';
},
'online' => function () {
echo 'Site is online';
}
]);
Written by Morrison Laju
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#