-
-
Save paragonie-scott/593ada3f89638b3e04e5 to your computer and use it in GitHub Desktop.
Ugly Antipattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function globalvar($name, $action = 'get', $value = null) | |
{ | |
static $cache = []; | |
switch ($action) { | |
case 'get': | |
if (isset($cache[$name])) { | |
return $cache[$name]; | |
} | |
return null; | |
case 'set': | |
$cache[$name] = $value; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment