Php program to print the constant array using define function

A Php program to print the constant array using define function. In this program we can print the constant array using defined function. Arrays are a form of data structure in PHP that allows us to store several pieces of the same data type in a single variable, saving us the time and effort of having to create a new variable for each data type.

define("fruit", [
echo fruit[2];




What is consonant in php

Except for magic constants, which aren’t actually constants, PHP constants are names or identifiers that can’t be modified throughout the execution of the script. Constants in PHP can be defined in two ways: The define() function is used.

What is define function in php

A constant is defined with the define() function. Constants are similar to variables, with the following exceptions: The value of a constant cannot be modified once it has been set. A leading dollar symbol ($) is not required for constant names. Regardless of scope, constants can be accessed.