示例#1
0
<?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";
}
示例#2
0
文件: example.php 项目: chadetov/dalc
<?php

$db = new MySQLDalc();
$tc = new TestClass($db);
$ulist = $tc->testMethod();
echo '<pre>';
print_r($ulist);
echo '</pre>';
示例#3
0
<?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();