In-depth analysis of php magic methods and magic variables, built-in methods and built-in variables. Php built-in variable: DIRECTORY_SEPARATORDIRECTORY_SEPARATOR is a php built-in command that returns the path separator related to the operating
PHP magic method summary. 1. the _ get and _ set methods are designed for classes and their parent classes without declared attributes. _ get ($ property) access this method when an undefined property is called _ set ($ p
1. _ get, _ set
These two
PHP magic method learning. _ Set_state () var_export can export a set as a string that is executable PHP code. In the object-oriented PHP 5.1.0, a parameter named _ set_stat _ set_state () is introduced ()
Var_export can export a set as a string,
Php magic methods sleep () wakeup () _ sleep () and _ wakeup ()
Public array_ Sleep(Void)
Void_ Wakeup(Void)
The serialize () function checks whether a magic method _ sleep () exists in the class (). If this method exists, it is called first
After PHP5.0, PHP object-oriented commission more methods, make PHP more powerful!!
Some of the functions in PHP called Magic Methods, introduced here: in fact, in the general application, we need to use them!!
1.__construct () when an object is
PHP magic constant .? Php ************ note part of the magic constant 1: Unable to manually modify his value, so called constant 2: But the value changes with the environment, so it's called Magic --- magic constant _ FILE _ return
/****
****/
/
'; Echo ' does not exist in the method with parameters passed in'; echo Print_r ($arg), ''; }//Magic method __callstatic public static function __callstatic ($method, $arg) {echo ' does not exist ', $method, ' static method'; Echo ' also passed a
Summary of common PHP magic methods. Common magic methods include __tostring () _ Call () _ autoLoad () _ clone () _ GET () _ SET () _ isset () _ unset () 1. _ Tostring () is used to define the reference of the output object. it is often used to
I once remember Laruence mentioned that it was not recommended to use the "magic method". after that, I would subconsciously think about how to use the magic method. Is this a good photo? Since I have been busy with work and learning for the past
Some things, if not used frequently, can easily be forgotten, such as magic methods and magic constants.
Magic Method (Magic methods)
PHP's method of starting with two underscores is called a magic method, which plays a pivotal role in PHP. Magic
PHP magic function collections. For more information about php learning, see. 1. _ Construct ()
Called When instantiating an object,
When _ construct and a function with the class name both exist, __construct will be called and the other will not be
PHP magic quotes. The security of PHP lies in its default configuration of php. the ini-dist contains magic_quotes_gpcOn, which is called "MagicQuote". it is useful for PHP beginners. "Although the security of SQL injection in PHP lies in its
This article mainly introduces the function and usage of PHP magic method, combined with the example form simple analysis of PHP object-oriented programming common magic methods of the function and related use skills, the need for friends can refer
Example of php magic function _ call ()
Class {
Public $ name;
Function test1 ($ ){
Echo "test1111 ";
}
Function test2 ($ ){
Echo "test2222 ";
}
// When an
This article describes how to use PHP magic methods _ GET and _ SET. This article provides detailed comments in the code. For more information, see _ get () -when you read the value of an inaccessible attribute, __get () will be called.
_ Set
This article mainly introduces the security problem analysis caused by PHP magic quotes, which is very important for security coding! For more information, see the "\" character produced by extracting magic quotes in PHP. for example, the following
PHP magic constant today saw a magic variable, which was never seen before, __dir __. I checked it and found it was added in php5.3. By the way, let's take a few examples, explain the magic variables of php
1 :__ FILE __
The complete file path
_ Autoload () usagePhp ManualAutomatically load objectsMany developers create a PHP source file for each class definition when writing object-oriented applications. A major headache is that you have to write a long list of contained files at the
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.