-1

I'm in the process of creating a mobile site and I'm starting the task of converting our current app. I'm looking at using CodeIgniter's built-in user-agent class but I want to know if the following is possible:

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

if (!$this->agent->is_mobile()) {
  $this->_showPage("newquote/newquotemobile", 'Test Mobile Page', $viewData);
}
else {
  $this->_showPage("newquote/newquote", 'Test Page', $viewData);
}

Has anyone had any experience in using CodeIgniter's built in user-agent class?

4

1 回答 1

3

这几乎就是您想要的方式(确定用户代理是否是移动的),但我不明白您为什么选择否定条件。我认为是“!” 错误地在那里。

这就是您使用 CI 提供的用户代理类的方式。 http://ellislab.com/codeigniter/user-guide/libraries/user_agent.html

于 2013-05-20T15:12:09.380 回答