PHP object traversal

WBOY
Release: 2016-07-29 09:02:00
Original
1255 people have browsed it

Objects can be traversed using foreach, which can only traverse attributes and access

<code><span><span><?php </span><span><span>class</span><span>bee</span>{</span><span>public</span><span>$a</span> = <span>1</span>;
    <span>protected</span><span>$b</span> = <span>2</span>;
    <span>private</span><span>$c</span> = <span>3</span>;
}
<span>$obj</span> = <span>new</span> bee();
<span>foreach</span>(<span>$obj</span><span>as</span><span>$key</span> => <span>$val</span>){
    <span>echo</span><span>$key</span>.<span>'-'</span>.<span>$val</span>;
}</span></span></code>
Copy after login

PHP object traversal

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced object traversal in PHP, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!