class a { |
public $attr = 'a' ; |
private $attr1 = 'b' ; |
} |
class b extends a { |
public $attr = 'b' ; |
public function __construct(){ |
$pvars = get_class_vars(get_parent_class( $this ) ); |
$cvars = get_class_vars(get_class( $this )); |
$inter = array_intersect_key ( $pvars , $cvars ); |
if (! empty ( $inter )) { |
throw new Exception( "Can't declare parent's attribute!" ); |
} |
} |
} |
try{ |
$a = new b(); |
} catch (Exception $e ) { |
echo $e ->getMessage(); |
} |