$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>wp config - where should I write constants in wordpress?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

wp config - where should I write constants in wordpress?

matteradmin10PV0评论

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?

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?

Share Improve this question asked Dec 7, 2018 at 7:11 Abdus Sattar BhuiyanAbdus Sattar Bhuiyan 2232 silver badges16 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

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.

Post a comment

comment list (0)

  1. No comments so far