Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

How to define constant in PHP?

what is constant in PHP?

A variable whose value we cannot modify

Constant means fixed. We cannot change the value which we have fixed as fixed later.

The definition of when its occupant falls suggests that whenever you want to become a variable whose value is fixed, you do not want someone to change it accidentally. Or you change it yourself so that your program gets spoiled, then in that case we create a constant variable and we assign the value which cannot be modified later in any way nor correct. Ways nor wrongly.

Create a PHP Constant

To create a constant variable we use the define function,
Define () function is used to create constants.

The syntax is its definition. Write the value of the constant variable inside the double quotes as a comma and write the value, whichever variable is assigned to that value will write the value. Then by giving a coma, you will write the case-insensitive here, here the buy default false, here you can write two values ​​instead of case insensitive.
Either true or false, if you don’t write anything, it is considered by default falls. If you write true, then case-insensitive has been done.

Syntax:-

Define (“constant_variable”, value, case-insensitive)

Ex:-

  • define (“pi,3.14192”); <- Here “pi” is case-sensitive
  • define (“pi”, 3.141592, TRUE); <- Here “pi” is non-case-insensitive
  • define (“site”,”devopsschool.com”)

Create a constant with a case-sensitive name:

Example:

Create a constant with a case-insensitive name:

Example:-

Rule:- Some rules for writing the Constant variable

  • No need to start constant variable name with $ sign.
  • Name only starts with a letter and an underscore(_).
  • Variable name cannot start with a number.
  • It is case sensitive which implies that the variable num is lowercase is different from variable NUM in uppercase. But we can make it case insentive.
  • Constant are automatically global and can be used across the entire script.
  • Can’t use Predefined constant name e.g. PHP_VERSIon, PHP_OS etc
  • Can’t use reserved keyword. e.g. else, if etc.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

What is CodeIgniter and use cases of CodeIgniter?

What is CodeIgniter? CodeIgniter is an open-source PHP web application framework designed to simplify and accelerate web development. It follows the Model-View-Controller (MVC) architectural pattern and provides…

Read More

What is PHP and use cases of PHP?

What is PHP? Are you wondering what PHP is and how it works? Look no further! In this article, we will explore the ins and outs of…

Read More

Complete guide on PHP certification courses, tutorials & training

What is PHP Hypertext Preprocessor is known as PHP. Many developers use PHP, an open-source server-side programming language, to create websites. In addition, it is a general-purpose…

Read More

Complete PHP with Laravel Certification Guide & tutorials

What is PHP with Laravel? PHP was visioned eventually in the fall of 1994 by Rasmus Lerdorf. PHP means Hypertext Preprocessor. It’s a extensively- used, open source…

Read More

Top 50 PHP Interview Questions and Answers

1) What is PHP? PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. PHP is well suited for web development….

Read More

Complete guide of PHP certification courses, tutorials & training

PHP is a great beginner programming language for anyone who is wanting to cross over into the coding world. Though easy to learn, it is an extremely…

Read More