面向对象类的继承案例代码展示

<?php

class Good{
     
	private $_name;
	private $_price;
	
	
	}

class Book extends Good{
     
	//静态属性
	public static $_static_prop=0;
	
	private $_autor;
	private $_chubanshe;
	
	}

class phone extends Good{
     
	private $_brand;
	private $_chandi;
	}
$b= new  Book();
var_dump($b);
echo "
"
; $p=new phone(); var_dump($p); echo "
"
; echo Book::$_static_prop; echo "
"
; //父类不可以访问子类的静态属性 echo Good::$_static_prop; ?>

你可能感兴趣的:(面向对象类的继承案例代码展示)