Skip to content

Instantly share code, notes, and snippets.

@xemoe
Created June 20, 2015 10:44
Show Gist options
  • Save xemoe/6fc549bf2e9bb4828757 to your computer and use it in GitHub Desktop.
Save xemoe/6fc549bf2e9bb4828757 to your computer and use it in GitHub Desktop.
test.php
<?php
class Car {
public static function test() {
echo 'test';
}
}
class TestService {
private function model() {
return 'Car';
}
public function getTest1(){
echo Car::test();
}
public function getTest(){
// echo $this->mode()::test();
}
}
$app = new TestService();
$app->getTest1();
@xemoe
Copy link
Author

xemoe commented Jun 20, 2015

<?php

class Car 
{
    public static function test() 
    {
        echo 'test';
    }
}

class TestService 
{
    private function model() 
    {
        return 'Car';
    }

    public function getTest()
    {
        $ref = new ReflectionClass($this->model());
        $ref->getMethod('test')->invoke(null);
    }
}

$app = new TestService();
$app->getTest();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment