Home >Backend Development >PHP Tutorial >Basic form of creating objects in PHP

Basic form of creating objects in PHP

WBOY
WBOYOriginal
2016-07-29 09:02:541041browse

<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); }); });

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.

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