Rumah >pembangunan bahagian belakang >tutorial php >PHP之创建对象的基本形式
<code><span><span>class</span><span>p_obj</span>{</span><span>public</span><span>$val</span>; <span>public</span><span><span>function</span><span>func</span><span>()</span>{</span><span>echo</span><span>"new obj"</span>; } }</code>
<code><span>$obj_one</span> = <span>new</span> p_obj();</code>
<code><span>$obj</span> = <span>"p_obj"</span>; <span>$obj_two</span> = <span>new</span><span>$obj</span>();</code>
<code><span>$obj_three</span> = <span>new</span><span>self</span>; <span>//self指代类本身,这行代码只能在类内部使用</span></code>
<code><span>//通过对象创建对象</span><span>$obj_four</span> = <span>new</span><span>$obj_one</span>;</code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了PHP之创建对象的基本形式,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。