Constants

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
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Constants

Post by 9902468 »

This might sound silly, but I'd like to know if I can check if a constant is set. I have many constants that are, or are not, set according to page displayed, user input etc. once set, the value I have to keep is always the same, so using variable would be waste of everything. I've tried isset and if clauses, but always get same notice; undefined constant constant used assuming "constant" (PHP understands it as a string?)

So, is it possible, or am I forced to use variables?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post by 9902468 »

Thanks! it's so easy. (when you know it....)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

To be honest all I did was go to php.net and seach on constant, got this:
http://www.php.net/manual/en/function.constant.php
and found the function you needed from there.

Remember, the manual is your friend :wink:

Mac
Post Reply