Differences between const and define (PHP)

Source: Internet
Author: User
: This article mainly introduces the difference between const and define (PHP). If you are interested in the PHP Tutorial, please refer to it. Description: const is used to define the class member variables. at the same time, const itself is a language structure, and define is a function. const is much faster than define during compilation. Therefore, we recommend that you, use const when const can be used

Differences:
1. const is used for the definition of class member variables. it cannot be modified if its meaning is fixed. Define cannot be used for the definition of class member variables, but can be used for global variables.
2. const cannot be defined in condition syntax, but define can, for example, in if... Else...
3. const uses a normal constant name, and define can use an expression as the name
4. const can only accept static scalar values, while define can use any table expression.
5. const defines the sensitivity of constants in upper case and lower case, while define can use the third parameter (true) to specify whether the case is sensitive.

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above introduces the difference between const and define (PHP), including some content, and hopes to help those who are interested in PHP tutorials.

    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.