首页  >  文章  >  后端开发  >  PHP之对象遍历

PHP之对象遍历

WBOY
WBOY原创
2016-07-29 09:02:001281浏览

对象可以使用foreach进行遍历,只能遍历属性以及访问范围内的

<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>

PHP之对象遍历

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

以上就介绍了PHP之对象遍历,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn