<?php function err2exception($errno, $errstr) { throw new Exception("Error occuried: " . $errstr); } set_error_handler('err2exception'); class TestClass { function testMethod() { $GLOBALS['t'] = new stdClass(); } } try { TestClass::testMethod(); } catch (Exception $e) { echo "Catched: " . $e->getMessage() . "\n"; }
<?php $db = new MySQLDalc(); $tc = new TestClass($db); $ulist = $tc->testMethod(); echo '<pre>'; print_r($ulist); echo '</pre>';
<?php # Example #5 Interfaces with same method name not giving error why? interface TestInterface { public function testMethod(); } interface TestInterface2 { public function testMethod(); } class TestClass implements TestInterface, TestInterface2 { const PIA_VAL = 3.214; public function testMethod() { echo self::PIA_VAL; } } $oTC = new TestClass(); $oTC->testMethod();