PHP5 object-oriented explanation-(10) _ set () _ get () _ isset () _ unset () four methods. This article briefly introduces four methods for PHP5 object-oriented explanation-(10) _ set () _ get () _ isset () _ unset, if you have any questions,
In php object-oriented language, _ set _ get _ isset _ unset usage is introduced. We often see the usage of bit _ set _ get _ isset _ unset in php object orientation, but we do not understand why we should use these items, next we will introduce one
10. _ set () _ get () _ isset () _ unset () application of four methods In general, the class attribute is always defined as private, which is more in line with the actual logic. However, read the attributeAnd value assignment operations are very
PHP special methods: set (), get (), isset (), and unset ()
The _ set () method is used to set private property values.
The _ get () method is used to obtain private property values.
The _ isset () method is used to check whether the private
: This article mainly introduces the PHP magic methods __isset and _ unset. if you are interested in the PHP Tutorial, refer to it. In versions later than php5, classes can use magic methods. Php requires that all methods starting with two
The _ set () method is used to set private property values. The _ get () method is used to obtain private property values. The _ isset () method is used to check whether the private property value is set. The _ unset () method is used to delete
The __set () method is used to set the private property value.
The __get () method is used to get the private property value.
The __isset () method is used to detect whether a private property value is set.
The __unset () method is used to delete
1. The _ get and _ set methods are designed for attributes that are not declared in the class and their parent class: __get ($ property) this method is called when an undefined property is called; __ set ($ property, $ value) assigns & amp; 20540 to
Overloading in PHP differs from traditional object-oriented overrides, such as in Java:
class A{ public void methodName(参数1); public void methodName(参数1,参数2); public void methodName(参数1,参数2,参数3); ...}
Overloading in PHP is an "elegant"
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.