问下laravel里面$test = app('\App\Services\TestService');这样获取的$test是对象还是类呢?
情况是这样的,我那个TestService.php文件里面有
class TestService
{
protected $url;
public function __construct()
{
$this->url = 'test.com';
}
}
然后我再一个控制器里面获取url
$test = app('\App\Services\TestService');
echo $test->url;
就报错,当把url设置成public就可以
public:权限是最大的,可以内部调用,实例调用等。
protected: 受保护类型,用于本类和继承类调用。
private: 私有类型,只有在本类中使用。
所以我问下我这个$test是什么类型的
推荐文章: