Skip to content

Instantly share code, notes, and snippets.

@paragonie-scott
Created May 27, 2015 14:49
Show Gist options
  • Save paragonie-scott/593ada3f89638b3e04e5 to your computer and use it in GitHub Desktop.
Save paragonie-scott/593ada3f89638b3e04e5 to your computer and use it in GitHub Desktop.
Ugly Antipattern
<?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