This article mainly introduces the use of PHP class constants, examples of the concept of class constants in PHP, characteristics and related use of skills, the need for friends can refer to the following
The examples in this article describe the usage of PHP class
Python built-in constants and python Constants
IntroductionThere are not many built-in constants in Python. There are only six constants: True, False, None, NotImplemented, Ellipsis, an
Python implements unchangeable constants. python implements constants.
For various reasons, Python does not provide const Modifiers like C/C ++/Java. In other words, python does not have const
(): g_num1 = 10 result = g_num1 + 2 print ("result: % d" % result) before the add_num () function call) other () #################### result: 12 # result: 4 # result: 2 # g_num1: 3 # g_num2: 5 ####################
Access global variables in file 2.
# FileName: file2import file1file1. add_num () # g_num1 changed to test = file1.g _ num1 + 1 print ("test: % d" % test)
Avoid using global variables whenever possible. Different modules can freely access global variables, which may lead to unpredic
1. Custom Constants
the value of a constant can only be scalar data ( Boolean , integer , float and the string ) or null .
Once a constant is defined, it cannot be redefined or undefined.
There are two ways of defining this:
with define () function to define constants
Define (' STATUS ', 3); Case is not sensitive if the third argument is set to True
Echo STATUS;
with Const keyword to defin
Php customizes global constants and class constants/*** 1. define (name, value, case_insensitive) customizes global constants. the default value is case sensitive. * 2. const defines class constants. * 3. do not use "$" * 4. do no
Php customizes global constants and class constants *** 1. define (name, value, case_insensitive) customizes global constants. the default value is case sensitive. * 2. const defines class constants. * 3. do not use "$" * 4 before
/** * 1, define (name,value,case_insensitive) custom global constants, default case Sensitive * 2, Const defines class constants. * 3, the constant name do not use "$" * 4, the name of the constant all use uppercase letters. *///defines global constants Languagedefine (' LANGUAGE ', ' China '); Echo language;//language
another type, or some other fallback (dependent operator).See for details [Implementing arithmetic operations][3] ellipsis
Most of this special value is used to combine slice syntax that is extended for user-defined container data types. __debug__
This constant is true if Python is not started with AN-O option. Also the Assert statement.If Python does not start with the-o option, the constant is true, see
members, using classes to access static members "so that the individual accessors are also easy to distinguish""At the business logic level, it is possible to differentiate whether it is a static method: The method uses a non-static method if it is a certain instance object. If the method applies to all objects, set the method to a static method. 】Although a non-static method is also an object reference to the encoding area for execution, $this in the method can specify the object for operation
for first, and then the attribute is searched layer by level, which is the problem that needs attention."The overriding mechanism created by the inheritance chain is to ensure the priority of access and to ensure the personalization of subclasses""It is also important to note that in the overriding mechanism of inheritance, a property cannot be lower than the parent's original property (that is, if the parent class uses public, the subclass can only
specifications, so that other programmers to achieve
2, when multiple peer class, all need to implement a function, but the way to achieve different;
Summary:
1, the interface can not be instantiated, all the methods in the interface can not have the main;
2. A class can implement multiple interfaces, separating class demo implements if1,if2,if3{} with commas (
;start ();$p =new Phone ();$p->start ();
When to use the interface:1, set specifications, let other programmers to achieve2, when a number of peer class, all need to implement a function, but the way of implementation is different;Summary:1, the interface can not be instantiated, the interface of all methods can not have the subject;2, a class can implement multiple interfaces, separated by a comma
, but the way of implementation is different;
Summary:
1, the interface can not be instantiated, the interface of all methods can not have the subject;
2, a class can implement multiple interfaces, separated by a comma (,) class demo implements if1,if2,if3{}
3, the interface can have attributes, but must be constants, consta
[Python ③] basic python data types, variables and constants, pythonBasic Data Type
In Python, the following types of data can be processed directly:Integer
Python can process Integers of any size, including negative integers. The writing method in the program is the same as
Today look at the variables and constants of Python: Python3 C:\test.pyfirst, let's talk. The interpreter executes the Python process:1. Start the Python interpreter (in memory)2. Read the C:\test.py content from the hard disk into memory (this step is the same as the text editor)3. Execute code that reads into memoryI
loading function __autoload () provided by php to complete the process.
This function is automatically called when the script requires a class definition, but the class definition is not found on the page. At the same time, the required class name will be passed as a parameter to the _ autoload () function during the call: it will be executed every time. therefo
class defines a constant method (recommended method)//final修饰符public final class Constants { //私有构造方法 private Constants() {} public static final int ConstantA = 100; public static final int ConstantB = 100; ......}Called with the class. Constant name method. You need to priv
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.