I have to define a constants to use all over the entire project(i.e: single.php, category.php, my-template.php). Suppose I define a array constant to declare a list of browser name. i.e: array('firefox'=>'Mozilla Firefox','google_chrome'=>'Google Chrome'). Now this constant will be accessible within any php file in my project. I can do this in several ways. But what is the best practice?

up vote 2 down vote accepted

Depends on what your project is. If you're developing a theme you would define them at the top of your theme's functions.php file, and if you were developing a plugin you would put them at the top of your main plugin file.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.