<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>
The above introduces the basic form of creating objects in PHP, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.