Discover php implements arrayaccess, include the articles, news, trends, analysis and practical advice about php implements arrayaccess on alibabacloud.com
PHP pre-defined interface: ArrayAccess; php pre-defined arrayaccess. PHP pre-defined interface ArrayAccess, php pre-defined arrayaccess recently went home for the Chinese New Year, and the blog has not been updated. I feel that I have learned a lot
PHP pre-defined interface-ArrayAccess, php pre-defined arrayaccess
I recently went home for the Chinese New Year, and my blog has not been updated. I feel that I have learned a lot and missed many learning opportunities, just like what I often say
Brief introduction
An interface that provides the ability to access an object like an array.
Interface Summary
ArrayAccess {/* 方法 */abstract public boolean offsetExists ( mixed $offset )abstract public mixed
ArrayAccess interface introduction. A series of new interfaces are added in PHP5. You can learn about their applications in the series of articles translated by HaoHappy. At the same time, these interfaces and some implemented classes are classified
There are a number of new interfaces in PHP5. You can learn about their applications in the series of articles translated by Haohappy. At the same time, these interfaces and some of the implemented classes are classified as standard PHP Library (SPL)
There are a number of new interfaces in PHP5. You can learn about their applications in the series of articles translated by Haohappy. At the same time, these interfaces and some of the implemented classes are classified as standard PHP Library (SPL)
If you want to use an object as a PHP array, you need to implement the ArrayAccess interface.
The code is as follows:
Interface ArrayAccess
Boolean offsetExists ($ index)
Mixed offsetGet ($ index)
Void offsetSet ($ index, $ newvalue)
Void
Interface Arrayaccess
Boolean offsetexists ($index)
Mixed Offsetget ($index)
void Offsetset ($index, $newvalue)
void Offsetunset ($index)
The following example shows how to use this interface, but the example is not complete, but it can be
Copy Code code as follows:
Interface Arrayaccess
Boolean offsetexists ($index)
Mixed Offsetget ($index)
void Offsetset ($index, $newvalue)
void Offsetunset ($index)
The following example shows how to use this interface, and
Copy codeThe Code is as follows:Interface ArrayAccessBoolean offsetExists ($ index)Mixed offsetGet ($ index)Void offsetSet ($ index, $ newvalue)Void offsetUnset ($ index) The following example shows how to use this interface. The example is not
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.