Re: PHP Brain Teasers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Brown wrote:
>    What the hell?  Why not start a thread that can be fun and

... here's a easy one:

interface Currency {}
interface Employee {}

class Peanut implements Currency {}
class Primate implements Employee {}

abstract class HeadHunter {
    static function match(Currency $c) {
        if ($c instanceof Peanut) return new Primate;

        throw new Exception("never heard of outsourcing?");
    }
}

try {
    echo get_class(HeadHunter::match(new Peanut)),"\n";
} catch (Exception $e) { echo $e->getMessage(),"\n"; }

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux