Home >> PHP >> How do you define a constant in PHP

How do you define a constant in PHP

A constant value cannot change during the execution of the script. By default, a constant is case-sensitive. By convention, constant identifiers are always uppercase.constant name starts with a letter or underscore.

To create a constant, use the define() function.

Syntax

define(name, value)

Parameters:

Example

define("SITE_URL", "https://www.coderraj.com");

echo SITE_URL;

 

Post Your Comment

Next Questions
How To Write the FORM Tag for Uploading Files
What is the difference between include, include_once
What is the difference between require and require_once
What is difference between include_once and require_once
What is difference between include and require
What is meant by urlencode and urldecode
How To Get the Uploaded File Information
Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars
How do you pass a variable by value
How do I find out the number of parameters passed into function
How To Protect Special Characters in Query String
What is the difference between GET and POST
What are the different types of errors
If conditional statement
If else conditional statement
If else / else if conditional statement
Switch conditional statement
For loop
While loop
Do while loop
Foreach loop
Operators
Arithmatic operators
Assignment operators
Increment / Decrement Operators

Copyright ©2022 coderraj.com. All Rights Reserved.