How to check if a defined constant exists in PHP

0 votes

I am using fuelphp a PHP framework and I have 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.

How do I check if a constant exists in PHP?

These are the constants I need to check for:

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';

Can someone help me with this?

May 30, 2022 in PHP by Kichu
• 19,040 points
878 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to check if a string is an email address in PHP?

Hello, Try this without regular expressions: <?php ...READ MORE

answered Nov 3, 2020 in PHP by Niroj
• 82,840 points
3,954 views
0 votes
1 answer

How to check if a file exists from a url using php?

Hello, You have to use CURL function does_url_exists($url) { ...READ MORE

answered Nov 3, 2020 in PHP by Niroj
• 82,840 points
4,079 views
0 votes
1 answer

How can one check to see if a remote file exists using PHP?

Hello @kartik, You can instruct curl to use ...READ MORE

answered Nov 10, 2020 in PHP by Niroj
• 82,840 points
1,226 views
0 votes
1 answer

How to check whether property exists in object or class in php?

Hello @kartik, Using  property_exists( mixed $class , string $property ...READ MORE

answered Oct 1, 2020 in PHP by Niroj
• 82,840 points
6,425 views
0 votes
1 answer

How to Check for a Specific Type of Object in PHP

Hello @kartik, You can use instanceof: if ($pdo instanceof PDO) ...READ MORE

answered Oct 30, 2020 in PHP by Niroj
• 82,840 points
1,796 views
0 votes
1 answer

How to check an IP address is within a range of two IPs in PHP?

Hello @kartik, With ip2long() it's easy to convert your addresses ...READ MORE

answered Nov 3, 2020 in PHP by Niroj
• 82,840 points
3,591 views
0 votes
0 answers

PHP | define() vs. const

In PHP, there are two ways to ...READ MORE

Jun 1, 2022 in PHP by Kichu
• 19,040 points
900 views
0 votes
0 answers

Check if variable empty

Code: if ($user_id == NULL || $user_name == ...READ MORE

Jun 4, 2022 in PHP by Kichu
• 19,040 points
376 views
0 votes
0 answers

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

I'm running into a small issue with ...READ MORE

Aug 1, 2022 in PHP by Kithuzzz
• 38,000 points
2,643 views
0 votes
0 answers

PHP Constants Containing Arrays?

This fails in my case define('DEFAULT_ROLES', array('guy', 'development ...READ MORE

Aug 5, 2022 in Others by krishna
• 2,820 points
534 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP