Using Constant Values
Home Courses Community Support
Using Constant Values

Constants are the variables which can not be changed. Constants are accessable globaly and start with underscor or letter.

enlightenedConstant don't require $ to start.

Run below code on your PC or in CodeLAB.


//define constant 'Geeku' and pass a value
define ("Geeku", "Hello! Tell me what you want to learn today?");

// Print constant value
echo Geeku;


Hello! Tell me what you want to learn today?


In the above code we have used 'Geeku' as a constant variable and passed a value "Hello! Tell me what you want to learn today?

We use 'echo' to print the value of constant. In above code, the constant name is case sensitive.

For example: If we will use 'geeku' instead of 'Geeku' then it will show a PHP error that unndefined constant 'geeku' and will print 'geeku' only.

To avoid this situation, add a 'case_sensitive' valur 'True' followed by constant value.

Check below code.

define ("Geeku", "Hello! Tell me what you want to learn today?", true); //define constant 'Geeku' and pass a value with case sensitive true
echo geeku; // Print constant value by using constant name in lower case.

Now the output will be same:

Hello! Tell me what you want to learn today?



← Preview

Introducing Variables

Next →

Integer Float and String Data Types


Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.


  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App