How to get access the values of object which are starting from # in laravel dd(); php?

三世轮回 提交于 2020-06-16 18:34:08

问题


I used this "mobiledetect/mobiledetectlib": "^2.8" pkg of laravel for device detection and want to print the userAgent value.I call this method

$this->device = new MobileDetect();
dd($this->device)

After that i got this result:

now i want to print userAgent value. I have tried these code but not working.

dd($this->device->userAgent,$this->device["userAgent"]);

回答1:


I was also facing this issue a few days ago. I have a solution for it you can try.

$this->device->getUserAgent();

I was facing the same issue for access the #fillable values in the Model

dd(User::get()[0]->getFillable(),User::get()[0]);



来源:https://stackoverflow.com/questions/62213847/how-to-get-access-the-values-of-object-which-are-starting-from-in-laravel-dd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!