php - using namespace with array_map() -
in php web project, 2 subfolders within classes folder follows:
project\classes\app
project\classes\utility
there class called cleanse in utility subfolder. here copy of part of code in class:
namespace classes\utility; class cleanse { # attributes protected static $_ns = __namespace__; # methods public static function escape($values) { return is_array($values) ? array_map(self::$_ns.'\cleanse::escape', $values) : htmlentities($values, ent_quotes, 'utf-8'); } }
i wondering if $_ns should declared static or not. there better way declare attribute , if so, how can called within functions of class?
maybe i'm missing here, why putting value of php magic static namespace own variable? why not use namespace directly?
otherwise, can use private class can access variable , use $this->_ns, realistically, use namespace variable itself.
if decide declare statically, use self::_ns.
Comments
Post a Comment