コード例 #1
0
ファイル: bug60809.php プロジェクト: badlamer/hhvm
class ExampleParent
{
    private $hello_world = "hello foo\n";
    public function foo()
    {
        echo $this->hello_world;
    }
}
class Example extends ExampleParent
{
    use ExampleTrait;
}
trait ExampleTrait
{
    /**
     *
     */
    private $hello_world = "hello bar\n";
    /**
     *
     */
    public $prop = "ops";
    public function bar()
    {
        echo $this->hello_world;
    }
}
$x = new Example();
$x->foo();
$x->bar();
コード例 #2
0
<?php

class Example
{
    function foo()
    {
        echo "this is foo\n";
    }
    function bar()
    {
        echo "this is bar\n";
    }
    function __call($name, $args)
    {
        echo "tried to handle unknown method {$name}\n";
        if ($args) {
            echo "it had arguments: ", implode(', ', $args), "\n";
        }
    }
}
$example = new Example();
$example->foo();
// prints "this is foo"
$example->bar();
// prints "this is bar"
$example->grill();
// prints "tried to handle unknown method grill"
$example->ding("dong");
// prints "tried to handle unknown method ding"
// prints "it had arguments: dong
コード例 #3
0
ファイル: Extrunkit.01.php プロジェクト: exakat/exakat
<?php

class Example
{
    function foo()
    {
        return "foo!\n";
    }
}
// Rename the 'foo' method to 'bar'
runkit_method_rename('Example', 'foo', 'bar');
// output renamed function
echo Example::bar();