Accessing Object Properties with a Const value?

Associate
Joined
4 Mar 2007
Posts
315
Location
United Kingdom
I was curious suppose I have an abstract class in PHP such like:

Code:
define("SOME_CONST",'thisisaconst');

abstract class foo {

 public function myMethod() {
  return (object) array (
    SOME_CONST => 12
  )
 }

}

class bar extends foo{

 public function getsomething() {
   $someObject = $this->myMethod();
   $someObject->SOME_CONST; // This isn't possible.
 }

}

But is there a way in which I can refer to $someObject->SOME_CONST without having to call the SOME_CONST defined value?

Regards,
 
Back
Top Bottom