Usage of PHP define ()

Source: Internet
Author: User
Tags define function php define

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 ()

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.