I'm working on Zend_Validate_Hostname and have a need to access a method
within a class to get TLD specific regular expression characters. I don't
know the exact class name since it depends on the TLD in the hostname.
In Zend_Validate_Hostname::isValid() it works like so:
$className = 'Zend_Validate_Hostname_' . ucfirst($valueTld);
Zend::loadClass($className);
$obj = new $className;
$labelChars .= $obj->getCharacters();
With the class specifying the characters looking something like this:
class Zend_Validate_Hostname_De implements Zend_Validate_Hostname_Interface
{
public function getCharacters()
{
return '\x{00E1}...\x{00FE}';
}
}
I have no need to actually instantiate the class object, but I cannot see
any other way to access the getCharacters() method. Ideally I'd just do:
Zend::loadClass($className);
$labelChars .= $className::getCharacters();
But variable variables and classes doesn't work in PHP.
Any bright ideas on a better way to access the getCharacters() method. Or is
my current approach fine?
best wishes,
Si