Php magic methods and magic constants when we learn objects, we often hear teachers say that everything in the world is an object, so we will certainly hear concepts such as magic methods and magic constants, we will summarize the following points when studying the course:
What are common
Examples of php magic variable usage are described in detail, and php magic examples are described in detail. Examples of php magic variable usage are described in detail. Examples of php magic variables are described in this article. _ DIR _ is newly added in php5.3 and will be shared with you for your reference. Php
Php magic methods-constructor and Destructor, php magic constructor. Php magic methods-constructor and Destructor. php magic constructor php has a magical class of methods that are reserved and usually not explicitly called outside, they used php magic methods-constructor an
PHP Magic Constants Examples introduced, PHP Magic constants
The Magic constant PHP provides a lot of predefined constants to any script it runs, and our usual PHP magic constants are __class__ __function__ __line__ __file__ __dir__ __method__, This article introduces PHP Magic
PHP Magic Methods-constructors and destructors, PHP magic Constructors
PHP has a kind of magic method, these methods are reserved methods, usually not explicitly called outside, they use double underscore (__), they are called Magic Methods. PHP is also not recommended to define a method that starts with a double unde
Php magic function and magic constant 1. _ Construct () is called when an object is instantiated. When _ construct and a function with the same class name exist at the same time, __construct is called, and the other is not called. 2. _ Destruct () when deleting an object or an object operation is terminated, php magic functions and
For example, the third-order demon Phalanx is:
What is the rule of the demon Phalanx?
The Magic square is divided into magical square and even magic square. And even Magic square is divided into 4 multiples (such as 4,8,12 ...). And not multiples of 4 (e.g. 6,10,14 ...). ) Two kinds. The following are described separately.
2 Odd Rubik's Cube algorithmThe rule
It's hard to explain what you want to do. In short, with _ callstatic, you can save a lot.Code. In addition, this method can be called in the subclass. In combination with get_called_class, The subclass also performs magic.
Previously, when using the. NET Component Castle's activerecord,. Net version 2.0 can add a static getbyid method to each subclass. Now, PHP can also do this..
objects.
10. _ Isset ()
It is called to check whether an object property exists. For example, isset ($ C-> name ).
11. _ Unset ()
Unset an object property is called. For example, unset ($ C-> name ).
12. _ Set_state ()
Called when var_export is called. Use the return value of _ set_state as the return value of var_export.
13. _ Autoload ()
When instantiating an object, if the corresponding class does not exist, this method is called.
Magic
Python magic method-custom sequence, python magic
The magic methods related to custom sequences allow the classes we have created to possess sequence features, so that they can be used like python's built-in sequences (dict, tuple, list, string, etc ).
To implement this function, follow the python-related protocol. The so-called protocol is some agreed content. F
PHP overload and magic methods, PHP overload magic methods
First of all, you need to know what is the magic method of php. It is not magic. If you want to learn magic, it will be wrong!
Definition: PHP retains all class Methods Starting with _ (two underscores) as
Here are just a few of the magic methods that may be commonly used, such as __new__, which is not commonly used for meta-class initialization or __init__, is not introduced by anyone who uses this initialization.In fact, each magic method is in the internal method of rewriting, and do the same as the adorner behavior. It would be convenient to try to understand each detail decorator before trying to underst
Php magic method-attribute overload method, php magic attribute overload. Php magic method-attribute overload method, php magic attribute overload php has a very magical method, these methods are reserved methods, usually not explicitly called outside, they use the double-down php
Ingenious heavy-duty Magic Method __call (), heavy-duty magic __call
Work for half a year, feel this half-year learned more than the university four years of learning more, the main reason is calm down, the goal is clear, will not go all day and the game entangled together. College when in fact also realized that playing games will affect their normal study and work, but have been unable to control themsel
PHP has pre-defined 9 Super global variables, 8 magic variables, and 13 magic functions, which can be used anywhere in the script without a declaration. These variables and functions are frequently used in PHP development, and these variables and functions can easily help us solve many problems. The following is a detailed explanation of the super global variables, magi
For Magic quotes, it is a commonplace question for phper. Today I accidentally see an article, combined with PHP Manual and its reply, here to do a simple summary.
In short, the input data is automatically escaped when the Magic quotes is turned on. where all single quotes ('), double quotes ("), backslashes, and NULL characters are escaped (add a backslash), which essentially calls the Addslashes function
Magic constant:1. _ LINE __Returns the current row number in the file.2. _ FILE __Returns the complete file path and file name. If it is used in a include file, the include file name is returned. From PHP4.0.2, __file _ always contains an absolute path, while previous versions sometimes contain a relative path.3. _ FUNCTION __Returns the function name (New in PHP4.3.0 ). Starting from PHP5, this constant returns the name (case sensitive) when the func
When we learn objects, often hear the teachers say that the world is the object of everything, then also will hear the Magic method and magic constants and other concepts, then we learn to review the time of their own summary:
What are the common magic methods in PHP?
1) The Magic method all starts with __ double
PHP Magic Method Use example, PHP Magic Example
①__get/__set: Taking over the properties of an object
When accessing a non-existent object property:
index.phpCopy the Code code as follows:Define (' BASEDIR ', __dir__); Defining a root directory constantInclude BASEDIR. ' /common/loader.php ';Spl_autoload_register (' \\common\\loader::autoload ');
$obj = new \common\object ();
When accessing a non-existent
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.