问题描述
因此,我正在使用一个名为 fuelphp 的PHP框架,并且此页面是 HTML 文件,因此无法在其中使用PHP.我还有另一个带有顶栏的文件,我的HTML文件将通过ajax调用.
So I'm using a PHP framework called fuelphp, and I have this page that is an HTML file, so I can't use PHP in it. I have another file that has a top bar in it, which my HTML file will call through ajax.
如何检查PHP中是否存在常量?
我要检查fuelphp框架文件的位置.
How do I check if a constant exists in PHP?
I want to check for the the fuelphp framework file locations.
这些是我需要检查的常量(实际上,我只需要检查其中之一):
These are the constants I need to check for (actually, I only have to check one of them):
define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR);
define('APPPATH', realpath(__DIR__.'/fuel/app/').DIRECTORY_SEPARATOR);
define('PKGPATH', realpath(__DIR__.'/fuel/packages/').DIRECTORY_SEPARATOR);
define('COREPATH', realpath(__DIR__.'/fuel/core/').DIRECTORY_SEPARATOR);
require APPPATH.'bootstrap.php';
我意识到这些不是变量,而是常量...
edit:
I realized that these aren't variables they are constants...
推荐答案
首先,这些不是变量,而是常量.
First, these are not variables, but constants.
您可以使用 defined()
函数检查它们的存在:
And you can check their existence by using the defined()
function :
bool defined ( string $name )
这篇关于如何检查PHP中是否存在常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!