查找或列出PHP文件中使用的所有常量 [英] Find or list all constants used in a PHP file
问题描述
如何管理常量?
How to manage constants?
我正在使用zencart作为我的网站。
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
问题是我有几天删除了常量可以从任何php文件中删除,但我不会在english.php中删除它。
一次又一次,我不知道english.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.
有没有办法知道php文件中使用了哪些常量?
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具有人类已知的每项任务的功能。
PHP has a function for every task known to mankind.
这包括 get_defined_constants()
函数。
This includes the get_defined_constants()
function.
这篇关于查找或列出PHP文件中使用的所有常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!