Home  >  Article  >  Backend Development  >  How to use define() function in php

How to use define() function in php

王林
王林Original
2020-08-29 14:48:042909browse

How to use the define() function in php: The define() function is used to define a constant, syntax: [define(name,value,case_insensitive)]. For example: [define("GREETING","Hello world!")].

How to use define() function in php

Function:

define() function is used to define a constant.

(Recommended tutorial: php video tutorial)

Grammar:

define(name,value,case_insensitive)

Parameter introduction:

  • name is required. Specifies the name of the constant.

  • value is required. Specifies the value of the constant.

  • case_insensitive Optional. Specifies whether constant names are case-sensitive. If set to true, it is not case sensitive. Default is false (case sensitive).

(Related recommendations: php training)

Example:

Define a case-sensitive constant:

<?php
define("GREETING","Hello world!");
echo constant("GREETING");
?>

Output:

Hello world!

Define a case-insensitive constant:

<?php
define("GREETING","Hello world!",TRUE);
echo constant("greeting");
?>

Output:

Hello world!

The above is the detailed content of How to use define() function in php. 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