A class implementation of ENUM within PHP the class can be declared and used as such:
enum('Gender', array('Male', 'Female'));
$g = Gender::Male();
To me this appears that Male is now a function of a class called gender that was created/named based on a passed in string.
and simpleXML in PHP can take a GPX file and all of sudden have, what appears to me to be, functions that use the names of nodes in the file. Once again it appears to me that PHP was able to take a string and create a class with that same string value.
The enum code which I can somewhat read has the following
Code: Select all
foreach ($args as $k => $enum) {
$static_method = 'public static function ' . $enum .
'() { return ' . $enum . '::instance(); }';
$enums[$static_method] = '
class ' . $enum . ' extends ' . $base_class_name . '{
private static $instance = null;
protected $value = "' . addcslashes($k, '\\') . '";
private function __construct() {}
private function __clone() {}
public static function instance() {
if (self::$instance === null) { self::$instance = new self(); }
return self::$instance;
}
}';
What is happening here and as far as a google search to learn more of what is happening here what are the correct/effective keywords to use to get useful results.