Home >Backend Development >PHP Problem >What does define in php mean?

What does define in php mean?

青灯夜游
青灯夜游Original
2021-10-13 18:00:182482browse

define means "define" and is a built-in function in PHP. Its function is to define a constant. The syntax is "define(constant name, value, $case_insensitive)"; the parameter "$case_insensitive" specifies the constant. Whether the name is size-sensitive, if true, it will not be distinguished.

What does define in php mean?

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

What does define in php mean?

define is a built-in function in PHP used to define a constant.

The so-called constant is a quantity that cannot be changed. Once a constant in PHP is defined, it cannot be modified or undefined.

Legal constant names can only start with letters and underscores, and can be followed by letters, numbers, or underscores of any length. In PHP, you can define a constant through the define() function. The syntax of the define() function is as follows:

define($name,$value , $case_insensitive)
Parameters Description
$name Required. Specifies the name of the constant.
$value Required. Specifies the value of the constant.
$case_insensitive

Optional. Specifies whether constant names are case-sensitive.

If set to true, it will not be case sensitive. Default is false (case sensitive).

Example:

Define a case-sensitive constant:

<?php
header("Content-type:text/html;charset=utf-8");
define("WebSite","PHP中文网");
echo constant("WebSite");
?>

Output result:

What does define in php mean?

Define a case-insensitive constant:

<?php
header("Content-type:text/html;charset=utf-8");
define("WebSite","PHP中文网",TRUE);
echo constant("website");
?>

Output result:

What does define in php mean?

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What does define in php mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn