Skip to content

Comment on Underscore.phpparent

Comments

But in a way, using the namespace like suggested is much more PHP-ish. After all, your class does not have sensible instances. There is not much OOP about it.

Where there is something not-much-OOP about something, PHP supplies global functions (compare md5() to 5 lines of Java code) instead of classes. So, using global functions would. in many ways, be much more PHP-ish than using static class methods (which is more Java-ish if you ask me).

Of course, you don't want to pollute the global namespace too much, so using the '_' namespace sounds excellent. I really like the idea.

Namespaces might be more PHP-ish, but I was primarily concerned with being Underscore-ish.

I'm also not entirely opposed to the namespace approach, but syntactically I would rather call:

  __::foo('bar');
than
  use _;  
  __\foo('bar');
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.