Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Environment {
- protected $_source;
- public final function __construct(array &$source = array()) {
- if (empty($source)) {$source = $_SERVER;}
- $this->_source = array();a
- foreach( $source as $key => $value ){
- $this->_source[ convertName($key) ] = &$source[$key];
- }
- }
- private function convertName( $key ){
- $functionName = implode('', array_map(function ($in) {return ucfirst($in);}, explode('_', strtolower($key))));
- return $functionName;
- }
- protected function _get($key) {
- if (isset($this->_source[$key])) {return $this->_source[$key];} return NULL;
- }
- }
- $e = new Environment();
- echo $e->HttpUserAgent;
Add Comment
Please, Sign In to add comment