Use static function and call static function in another class

 In this example i'm creating an Static function in my Test class and passing it, inside the test function of TestController

Uploading: 149232 of 149232 bytes uploaded.


Test.php
<?php

namespace App\My;

class Test
{

    public static function my()
    {
        return "hello world";
    }

}

TestController.php

<?php

namespace App\Http\Controllers\Test;
use App\My\Test;
class TestController extends Controller
{
public function test()
    {
        return Test::my();
    }
}

Output


Comments