如何访问在laravel dd()中从#开始的对象的值;PHP的? [英] How to get access the values of object which are starting from # in laravel dd(); php?

查看:59
本文介绍了如何访问在laravel dd()中从#开始的对象的值;PHP的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此 "mobiledetect/mobiledetectlib":"^ 2.8" laravel pkg进行设备检测,并希望打印 userAgent 值我称这种方法

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:

现在我要打印userAgent值.我已经尝试过这些代码,但是无法正常工作.

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

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

推荐答案

几天前我也遇到了这个问题.我有一个解决方案,您可以尝试.

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

$this->device->getUserAgent();

在访问模型中的 #fillable 值时,我遇到了同样的问题

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

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

这篇关于如何访问在laravel dd()中从#开始的对象的值;PHP的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆