Deep Dive into PHP define () functions and defined () Functions _php Tutorial

Source: Internet
Author: User
Tags php define
The Define () function defines a constant.
The purpose of the Define () function is to define a constant.
Constants is much like variables, except for the following differences:
constants [constant] and variables [variable] have many similarities, so it is easy to confuse; below, we enumerate the differences between constants [constant] and variables [variable]:

A constant ' s value cannot be changed after it is set
A constant value cannot be changed after it has been specified;
constant names do not need a leading dollar sign ($)
When setting constants, you do not need to precede the "$" symbol;
constants can accessed regardless of scope
Constants can be accessed by domains of all scopes;
constant values can only be strings and numbers
The value of a constant can only be "strings [string]" and "numbers [number]";

Syntax
Grammar
Copy the Code code as follows:
Define (name,value,case_insensitive)

Parameter
Parameter
Description
Describe
Name Required. Specifies the name of the constant
Necessary parameters. Specify the name of the constant
Value Required. Specifies the value of the constant
Necessary parameters. Specifying the value of a constant
Case_insensitive Optional. Specifies whether the constant name should be case-insensitive. If set to TRUE, the constant would be case-insensitive. Default is FALSE (case-sensitive)
Optional parameters. Specifies whether the name of the constant is case insensitive [case-insensitive]. If set to true, the letter case is not distinguished, and if set to false, the letter case is distinguished. The default value is: False

Example 1
Case 1
Define a case-sensitive constant:
Specify a constant (case-sensitive):
Copy CodeThe code is as follows:


The output of the code above would be:
The code above will output the following result:
Copy CodeThe code is as follows:
Hello you! How is you today?

Example 2
Case 2
Define a case-insensitive constant:
Specify a constant (case insensitive):
Copy CodeThe code is as follows:


The output of the code above would be:
The code above will output the following result:
Copy CodeThe code is as follows:
Hello you! How is you today?

The defined () function checks whether a constant exists.
The purpose of the defined () function is to check whether a constant exists.

Returns TRUE If the constant exists, or FALSE otherwise.
Returns true if the constant exists, or false if it does not exist.

Syntax
Grammar
Copy the Code code as follows:
Defined (name)

Parameter
Parameter
Description
Describe
Name Required. Specifies the name of the constant to check
Necessary parameters. Specifies the name of a constant object

Example
Case
Copy the Code code as follows:


The output of the code above would be:
The code above will output the following result:
Copy the Code code as follows:
1

http://www.bkjia.com/PHPjc/327310.html www.bkjia.com true http://www.bkjia.com/PHPjc/327310.html techarticle the Define () function defines a constant. Define () functions: Defines a constant. Constants is much like variables, except for the following differences: constant [Constan ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.