Using classes as namespaces: good style?

From: Christian Hackl (
Date: 03/04/05

Date: Fri, 04 Mar 2005 22:04:13 +0100

Is it considered good style to use classes as namespaces in PHP (that
is, PHP 4.3.1)?


class MyClass
  function test() { echo 'MyClass::test'; }

class YourClass
  function test() { echo 'YourClass::test'; }


Reason is: I've got several functions that do almost the same thing, yet
giving them all different names may result in long, ugly, and
error-prone names like getArticleUpperRowUsingHeading.

Using proper parameters like getArticleRow($side, $using_heading) is
also out of question, because I wish to use the functions as variable
functions (call_user_func). The custom arguments (they'd all differ from
function to function) logically wouldn't even be known by the caller.

Putting the functions into classes looks like an acceptable alternative
to me, though doing so may actually be very stupid... I don't know which
way to go :)

Christian Hackl