Jump to content

How to point var to class like this: '$className::getTracksAndArtists() '


figmented

Recommended Posts

I need to point a variable to a class using the scope resolution operator.

 

I use the following to point a var to a class using the method operator:

 

$className = 'Users';

$className->getAll();

 

This works but when I try:

 

$className = 'Users';

$className::getAll();

 

...I get the Hebrew error "unexpected T_PAAMAYIM_NEKUDOTAYIM" which means "unexpected double colon"

 

Does anyone know how to do this and/or if this is possible?

 

Thanks!

 

Best,

Christopher Tate

www.figmented.com

No ALL CAPS. I'll change it this time, but next time I'll just lock it.

 

To answer your question, only way this is possible is with call_user_func or call_user_func_array (or Reflection, but lets not complicate matters).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.