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

Basic form of creating objects in PHP

WBOY
Release: 2016-07-29 09:02:54
Original
1032 people have browsed it

<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>
Copy after login
<code><span>$obj_one</span> = <span>new</span> p_obj();</code>
Copy after login
<code><span>$obj</span> = <span>"p_obj"</span>;
<span>$obj_two</span> = <span>new</span><span>$obj</span>();</code>
Copy after login
<code><span>$obj_three</span> = <span>new</span><span>self</span>;
<span>//self指代类本身,这行代码只能在类内部使用</span></code>
Copy after login
<code><span>//通过对象创建对象</span><span>$obj_four</span> = <span>new</span><span>$obj_one</span>;</code>
Copy after login
').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.

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