Home > Backend Development > PHP Tutorial > 子类承袭父类 父类private问起求各位大神详解

子类承袭父类 父类private问起求各位大神详解

WBOY
Release: 2016-06-13 12:41:59
Original
803 people have browsed it

子类继承父类 父类private问起求各位大神详解

<?php <br />
class A{<br />
	<br />
	private function test($n){<br />
		echo "11";<br />
	}<br />
}<br />
class B extends A{<br />
	function test(){<br />
		echo "22";<br />
		<br />
	}<br />
}<br />
class C extends A{<br />
<br />
}<br />
$b1=new B();<br />
$b1->test();<br />
?>
Copy after login
 此代码中父类有个private方法 PHP规则不是子类不能继承父类的private方法吗 可是我在子类内写了同名的方法 当其中一个有参数时就报错 如果两个都没有就没问题 请问为什么。。。。。

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