Naming a class with a variable/constant ... possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hamr23
Forum Newbie
Posts: 4
Joined: Sun Feb 03, 2008 1:05 am

Naming a class with a variable/constant ... possible?

Post by hamr23 »

:oops: Hello everyone, first post here...

I don't know if it's a stupid question... I have searched for it and didn't find any answer...

I want to have a constant defined in my globals file, so I can add a prefix to all the defined classes in my app... I'm pretty sure it isn't best practice, but I'm just curious...

Thanks for your time!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Naming a class with a variable/constant ... possible?

Post by Chris Corbyn »

Not possible sorry. You can use eval() but the overhead would make it pointless. Namespacing using the name of your library/application/project has worked well for years, I'd stick with that ;)
hamr23
Forum Newbie
Posts: 4
Joined: Sun Feb 03, 2008 1:05 am

Re: Naming a class with a variable/constant ... possible?

Post by hamr23 »

Yeah, I expected that answer... I don't know... maybe it's time for me to stop drinking coffee... LoL

Thanks !!
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Naming a class with a variable/constant ... possible?

Post by Jonah Bron »

Or cut down? :D

Oh, and welcome to the PHPDN! (also known as the DevNet)
Post Reply