[ create a new paste ] login | about

Link: http://codepad.org/vStYX1Kz    [ raw code | output | fork ]

synx508 - PHP, pasted on Sep 5:
<?php

interface ia {
    const c = 'Sea';
}

class Foo implements ia {
	
	// const c = "Lake";  
	
	// Attempting to override ia's constant c in
	// this class triggers a fatal error.
	
}

class FooBar extends Foo implements ia {
	
	const c = 'Ocean'; // No error, class constant
	 		   // overriding ia's definition.
	
	public function show(){
		// ia's definition is still accessible.
	  return ia::c;
	}
}

$i = new FooBar;
echo FooBar::c;
echo $i->show();

?>


Output:
1
OceanSea


Create a new paste based on this one


Comments: