Original address: http://www.manongjc.com/article/491.html
Const is the definition of a class member constant, which cannot be changed after the definition, and define we define global constants so that we can access them elsewhere but not change
Const and define all define constants in PHP, but what are their specific differences? In fact, very simple const is used for the definition of a class member variable, once defined and cannot change its value. Define defines a global constant that
The difference between define () and const in php is described in detail. In php, both define () and const () can define constants. So what is the difference between define () and const? many programmers do not understand this, next I will introduce
: This article mainly introduces php programming notes. if you are interested in PHP tutorials, please refer to them. Three methods for php to obtain POST data
Php image watermarking source code
Php + ajax + json is the simplest example.
Php Chinese
Php programming notes-three methods for obtaining POST data from small_123 php
Php image watermarking source code
Php + ajax + json is the simplest example.
Php Chinese character to pinyin source code
Php traverses the Directory, generates the md5
Note: Define cannot be defined in a class, and the const must be defined in a class, and the const must be accessed by the class name:: Variable name
1. Const is used for class member variable definition once defined and cannot change its value.
Three ways to get post data from PHP
PHP image plus watermark source code
One of the simplest examples of Php+ajax+json
PHP Chinese Pinyin Source code
PHP iterates through directories, generates MD5 values for each file in the directory, and writes
From: Http://stackoverflow.com/questions/2447791/define-vs-constSame point: Both can define constantsConst foo = ' Bar ';d efind (' foo ', ' Bar ');The disadvantage of const:1.const must be declared in Top-level-scope (top-level domain):For example:
As we all know, define defines constants. What if we define constants in a class? Of course, define cannot be used, but const can be used, for example: The code is as follows:Copy code Define ('php', 'I love php'); // constants are usually
In PHP define () and const () can define constants, then the difference between define () and const exactly where, this many programmers do not understand, I would like to introduce to you some of this function usage ratio.
The difference between
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.