Define () function understanding 1 (focusing on the understanding of the function)
The Define () function defines a constant.
Characteristics of constants:
Constants are similar to variables, except that, after setting, the value of a constant cannot change the constant name, does not require a dollar sign ($) at the beginning, and the scope does not affect access to the constant, which can only be a string or a number.
Define function Understanding 2 (emphasis on parameter understanding)
Grammar
Define (name,value,case_insensitive)
Parameters
Describe
Name is required. Specifies the name of the constant. The name parameter is the first argument of the Define function and is capitalized;
Value is required. Specifies the value of the constant. Value is typically a string or a number
Case_insensitive
Optional. Specifies whether the name of the constant is case sensitive.
If set to true, the case is not sensitive. The default is False (case sensitive).
Define function Understanding 3 (emphasis on case understanding)
Issue 1: A case-sensitive constant:
<?php
Define ("HF", "Hi friend!"); How the/1.define function is understood;
ECHO constant ("HF"); the//1.case_insensitive parameter defaults to False (case sensitive) how the 2.constant function is understood, and how the parameters within the 3.constant are understood;
?>
The output is: Hi friend!
Note: The symbol input is accurate, otherwise error prone;
Define function Understanding 4
Issue: 2: A case insensitive constant:
<?php
Define ("HF", "Hi friend!", TRUE), how the//1.define function is understood, and how the 3 parameters within 2.define are understood;
ECHO constant ("HF"); How the 1.echo function is understood, how the 2.constant function is understood, whether the 3.constant function input can be case insensitive, and how the parameters within the 4.constant function are understood;
?>
The result of the output is: Hi friend!
Usage of PHP define ()