PHP----------the constants defined by the const and define () define the difference between constants?

Source: Internet
Author: User
Tags define function

Usage One: const is used for class member variables, once defined cannot be modified, define is used for global constants, is not used for definitions of class member variables, const can be used in classes or outside classes, define cannot.

Definition: const constant NAME = value; No $ symbol
Access: Class Name:: Constant Name or interface name:: Constant name as

    

is to access the direct constant name outside the class


Usage Two: const defines a constant large lowercase sensitive, while define can specify case sensitivity by a third argument (true for case insensitivity). Defines a constant at run time. Define (' TXE ', 100,true);


Usage Three: const cannot define a constant in a conditional statement, and the Define function can. if ($a >10) {define (' LE ', ' Hello ');}

PHP----------the constants defined by the const and define () define the difference between constants?

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.