Symfony2 - 如何检查我们是否被移动设备调用 [英] Symfony2 - How to check if we are being called from a mobile device
本文介绍了Symfony2 - 如何检查我们是否被移动设备调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 Symfony2,无论我是从移动设备还是从桌面网络浏览器调用,我都需要检查控制器.
Using Symfony2, I need to check in the controller wether I am being called from a mobile device or from a desktop web browser.
根据请求的来源,根据屏幕大小和条件呈现不同的树枝模板.
Depending on the origin of the request, render different twig templates according to the screen sizes and conditions.
这样做的好方法是什么?我们在控制器中有什么可以检查这个?
What would be a good approach to do this? What do we have in the Controller to check this?
推荐答案
我确信 Symfony 也有一些封装的命令来执行此操作,但是:
I'm sure Symfony has some wrapped command to do this as well but:
$_SERVER['HTTP_USER_AGENT']
将为您提供 user-agent
字符串,该字符串包含字符串Android verNum".
will give you the user-agent
string which tents to have a string "Android verNum".
这篇关于Symfony2 - 如何检查我们是否被移动设备调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文