PHP define vs const

0 votes

In PHP, there are two ways to declare constants :

  1. With define keyword

    define('FOO', 1);
    
  2. Using const keyword

    const FOO = 1;
    

  • What are the main differences between those two?
  • When and why should you use one and then use the other?
Jun 1, 2022 in PHP by Kichu
• 19,050 points
632 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
0 answers

php var_dump() vs print_r()

What is the difference between var_dump() and print_r() in terms of ...READ MORE

May 28, 2022 in PHP by Kichu
• 19,050 points
370 views
0 votes
0 answers

PHP "php://input" vs $_POST

I want to know what is the ...READ MORE

Jun 9, 2022 in PHP by Kichu
• 19,050 points
511 views
0 votes
0 answers

PHP Elvis operator vs null coalescing operator

Can someone clarify the differences between PHP's ...READ MORE

Aug 3, 2022 in PHP by Kithuzzz
• 38,010 points
575 views
0 votes
0 answers

How to echo define value in PHP?

 Code : <?php define("SITENAME","Page TITLE");?> I want to echo ...READ MORE

Aug 6, 2022 in PHP by Kithuzzz
• 38,010 points
291 views
0 votes
0 answers

getenv() vs. $_ENV in PHP

What is the distinction between $_ENV and ...READ MORE

Aug 8, 2022 in PHP by narikkadan
• 63,420 points
1,125 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
9,643 views
0 votes
0 answers

How to check if a defined constant exists in PHP?

I am using fuelphp a PHP framework and I ...READ MORE

May 30, 2022 in PHP by Kichu
• 19,050 points
673 views
0 votes
0 answers

How to add elements to an empty array in PHP?

I define an array in PHP : $cart ...READ MORE

Jun 3, 2022 in PHP by Kichu
• 19,050 points
738 views
0 votes
0 answers

PHP - If variable is not empty, echo some html code

I want to display some HTML code ...READ MORE

Jun 4, 2022 in PHP by Kichu
• 19,050 points
634 views
0 votes
0 answers

Static variables in PHP

Can someone please explain to me what ...READ MORE

Jun 12, 2022 in PHP by narikkadan
• 63,420 points
325 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