Created
January 8, 2012 16:34
-
-
Save RalfAlbert/1578910 to your computer and use it in GitHub Desktop.
Simple DataContainer with overwrite protection
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 | |
class DataContainer | |
{ | |
private static $data = array(); | |
public static function __set( $name, $value ){ | |
if( ! isset( self::$data[$name] ) ) | |
self::$data[$name] = $value; | |
else | |
return FALSE; | |
return TRUE; | |
} | |
public static function __get( $name ){ | |
if( isset( self::$data[$name] ) ) | |
return self::$data[$name]; | |
else | |
return NULL; | |
} | |
} | |
$dc = new DataContainer; | |
$dc->FILE = basename( __FILE__ ); | |
var_dump( $dc->FILE ); | |
$dc_two = new DataContainer; | |
$dc_two->FILE = 'mettigel'; | |
var_dump( $dc->FILE ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment