How to manage constants?
I am using zencart for my site.
I add all global constants in:
includes/languages/english/english.php
and my contants use in any of my pages, such as:
includes/modules/meta_tags.php
The problem is that some days I delete a constant from any php file, but I dont remove it in english.php.
Time after time, I dont know what constants in english.php are in use and where are they used.
Is there any way to know what constants are used in a php file?
<?php
// includes/languages/english/english.php
define('HELLO','hello');
define('WORLD','world');
?>
<?php
// includes/modules/meta_tags.php
echo HELLO;
?>
<?php
// includes/modules/product_listing.php
echo WORLD;
?>
PHP has a function for every task known to mankind.
This includes the get_defined_constants()
function.
some ides, like netbeans, phpstorm, and probably many others have features like "find usages" and "refactor" which are really useful when renaming/updating/deleting, and they support constants.
this doesn't tell you "what comments are used in a specific file", but, i'm guessing its useful to you for similar purposes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With