Home > Backend Development > PHP Tutorial > Getting Started with PHP 8 Object Oriented 3 Interface

Getting Started with PHP 8 Object Oriented 3 Interface

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-28 08:26:21
Original
1103 people have browsed it

Keyword interface


The interface cannot have implemented methods


Cannot use data, but can have constants


JAVA interface: http://blog.csdn.net/a289672082/article/details/51518398
<code><span><span><?php</span><span><span>interface</span><span>Code</span>{</span><span>//public $data=123;  错误 接口中不能有访问属性的数据</span><span>const</span>   data =<span>123</span>;<span>//正确 接口中可以使用常量</span><span>public</span><span><span>function</span><span>_print</span><span>()</span>;</span><span>//public  function _print2(){};  错误,接口中不能用实现的方法</span>
}

<span><span>class</span><span>CPlusPlus</span><span>implements</span><span>Code</span>{</span><span>public</span><span><span>function</span><span>_print</span><span>()</span>
    {</span><span>echo</span><span>"std::cout <br>"</span>;

    }  
}

<span><span>class</span><span>JavaScript</span><span>implements</span><span>Code</span>{</span><span>public</span><span><span>function</span><span>_print</span><span>()</span>
    {</span><span>echo</span><span>"console.log(...) <br>"</span>;

    }
}

<span>$C</span> = <span>new</span> CPlusPlus();
<span>$JS</span> = <span>new</span> JavaScript();
<span>$C</span>->_print();
<span>$JS</span>->_print();
<span>?></span></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 PHP Getting Started 8 Object-Oriented 3 interface, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
Latest Issues
Print sql statement
From 1970-01-01 08:00:00
0
0
0
java - Print electronic form
From 1970-01-01 08:00:00
0
0
0
How to print key value in python for in
From 1970-01-01 08:00:00
0
0
0
Unable to print data
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template