First, the Magic method in PHPPHP has some special methods for object-oriented programming, which are called automatically at certain times, and we call this method magic.Second, the common magic methods and functions1. Constructor __construct ():
To paste the test code directly:
The code is as follows
Copy Code
Class Moshu { public function Moshu () { echo ' current class name: '. __class__. ""; echo ' Current method name: '. __function__. ""; The number
First, the Magic function(13)1, __construct ()Called when an object is instantiated, and when __construct and a function with the name of the class name are present, __construct is called and the other is not called.2, __destruct ()Called when an
After PHP5.0, PHP object-oriented commission more methods, making PHP more powerful!!
Some of the functions in PHP called Magic Method, introduced here: in fact, in the general application, we all need to use them!!
1.__construct () When
PHP built-in variable: directory_separatorDirectory_separator is a PHP built-in command that returns the path separator associated with the operating system, returns on Windows, and backs up on Linux or Unix-like, that's the difference. It is
Slowly long search night, the moon hanging__get ()-__get () is called when the value of the Inaccessible property is read__set ()-__set () is called when a value is assigned to an unreachable property '; Echo $example->public. " \ n "; Echo
In some web containers, some special characters will be converted. In this case, the ie xss filter developer has neglected its understanding at any place, which may lead to bypass.In php, if the "magic quotes" feature (magic_quotes_gpc = On) is
Magic variablePHP provides a large number of predefined constants to any script it runs.However, many constants are defined by different extensions, and are only present when the extensions are loaded, either dynamically after loading, or they are
PHP treats all methods starting with _ (two underscores) in the class as magic methods. It is generally recommended that you do not add _ as the prefix before the custom method.
Magic method:
1._ Construct ()
The default constructor of the class. If
The server space provided by the general Space quotient default PHP directive MAGIC_QUOTES_GPC is on, that is, open. You can then use the stripslashes () function to remove the auto-added backslash. The usage is: for example, the variable containing
(1) first knowledge of magic methods
Php5.0 has provided us with many features since its release.
Object Features, especially providing us with a lot of easy-to-use magic methods that can simplify our coding and better design our system. Today, let'
Php tutorial magic function concentration camp
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 called.
2. _ Destruct ()
It
Since the release of Php5.0, many object-oriented features have been provided for us, especially a lot of easy-to-use magic methods. These magic methods allow us to simplify our coding, better design our system. Today, let's get to know the magic
PHP shield decryption tool. I analyzed the knowledge points used in the decryption process of Alibaba Cloud security two days ago. I sorted out the tools last night and encrypted them by the way. This is what we said yesterday. let's take a look at
In php, the magic constants _ FILE _, _ LINE _ ,__ FUNCTION _ are used. This article mainly describes the magic constants _ FILE _, _ LINE _ ,__ FUNCTION __. if you need them, you can refer to a simple and practical example. Name Description _ FILE _
Some functions called Magic methods in PHP are introduced here: in fact, they are used in common applications !! After PHP5.0, php provides more object-oriented methods to make php more powerful !!
Some functions called Magic methods in PHP are
Some of the functions in PHP called Magic Methods, introduced here: in fact, in the general application, we need to use them!!
After PHP5.0, PHP object-oriented commission more methods, make PHP more powerful!!Some of the functions in PHP called
Magic Constants1. LineReturns the current line number in the file.2. FILEReturns the full path and file name of the file. If used in the include file, the include filename is returned. Since PHP 4.0.2, FILE always contains an absolute path, and 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.