用于开发 .mobi 网站的 PHP 框架

发布于 2024-08-06 04:17:44 字数 1539 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

撕心裂肺的伤痛 2024-08-13 04:17:45

我还没有听说过专门针对移动客户端的 PHP 框架。如果我是你,我不会尝试找到一个专门的框架,而只是定义你的一般需求,然后看看哪个框架可以最好地满足它们。不同客户的识别可以轻松集成到任何现有框架中。

I haven't heard of a PHP Framework that specializes on mobile clients. If I were you I wouldn't try to find a specialized Framework but just define your needs in general and see which framework can cover them best. The recognition of the different clients can be easily integrated into any existing framework.

强辩 2024-08-13 04:17:45

Codeigniter 有一个名为 用户代理 的类。

但是,您可能必须为移动浏览器创建自己的类。

用户代理类提供的功能可帮助识别有关访问您网站的浏览器、移动设备或机器人的信息。此外,您还可以获得引荐来源网址信息以及语言和支持的字符集信息。

例子:
当用户代理类初始化时,它将尝试确定浏览您站点的用户代理是 Web 浏览器、移动设备还是机器人。如果有的话,它还将收集平台信息。

$this->load->library('user_agent');

if ($this->agent->is_browser())
{
    $agent = $this->agent->browser().' '.$this->agent->version();
}
elseif ($this->agent->is_robot())
{
    $agent = $this->agent->robot();
}
elseif ($this->agent->is_mobile())
{
    $agent = $this->agent->mobile();
}
else
{
    $agent = 'Unidentified User Agent';
}

echo $agent;

echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)

Codeigniter has a class called User Agent.

However you may have to create your own class for mobile browsers.

The User Agent Class provides functions that help identify information about the browser, mobile device, or robot visiting your site. In addition you can get referrer information as well as language and supported character-set information.

Example:
When the User Agent class is initialized it will attempt to determine whether the user agent browsing your site is a web browser, a mobile device, or a robot. It will also gather the platform information if it is available.

$this->load->library('user_agent');

if ($this->agent->is_browser())
{
    $agent = $this->agent->browser().' '.$this->agent->version();
}
elseif ($this->agent->is_robot())
{
    $agent = $this->agent->robot();
}
elseif ($this->agent->is_mobile())
{
    $agent = $this->agent->mobile();
}
else
{
    $agent = 'Unidentified User Agent';
}

echo $agent;

echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)
池木 2024-08-13 04:17:45

移动浏览器与桌面浏览器一样,都有自己的问题和“特殊需求”,因此最好进行检查以查看您要输出到哪个浏览器,因为它可能会极大地影响输出。

Mobile browsers, like desktop browsers, all have their own problems and "special needs" so it would be a good idea to include a check to see what browser you are outputting to, because it could affect the output greatly.

久夏青 2024-08-13 04:17:44

CakePHP 作为内置 RequestHandler 组件的一部分,根据大量已知设备检查用户代理字符串,因此可以自动向这些客户端显示不同的内容。

这是它的比较列表:

iPhone、MIDP、AvantGo、BlackBerry、J2ME、Opera Mini、DoCoMo、NetFront、诺基亚、PalmOS、PalmSource、portalmmm、Plucker、ReqwirelessWeb、SonyEricsson、Symbian、UP.Browser、Windows CE、Xiino

即使您不使用 CakePHP,您可以查看该文件的源代码,以了解有关它如何处理这些请求的更多信息。

CakePHP, as part of the built-in RequestHandler component, checks the User Agent string against a big list of known devices and can therefore automatically display different content to those clients.

Here's the list it compares against:

iPhone, MIDP, AvantGo, BlackBerry, J2ME, Opera Mini, DoCoMo, NetFront, Nokia, PalmOS, PalmSource, portalmmm, Plucker, ReqwirelessWeb, SonyEricsson, Symbian, UP.Browser, Windows CE, Xiino

Even you don't go with CakePHP, you can take a look at the source of that file to see more about how it handles those requests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文