PHP constant definition define vs. const

Source: Internet
Author: User
Tags constant definition

Briefly summarize the differences between two constants in PHP that define keywords:

1, define is a function, const is the language structure, PHP compile-time const fast.
2, define can only be used outside the class, Const class within the class can be.
3. Constants defined by define are global, and const-defined constants are limited by namespaces.
4, define can be used in conditional statements, Const cannot.
5, define can be used as the name of the expression, const only the ordinary constant name.
6, const can only accept static scalar, and define can use any expression.
7, const-defined constants are case-sensitive, and define can specify case sensitivity by the third argument (true for case insensitivity).

PHP constant definition define vs. const

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.