한번 코드 테스트 해볼려고 코드를 작성해서 했는데
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Testview extends CI_Controller {
function index(){
$this->load->library('user_agent');
if ($this->agent->is_browser())
{
$agent = $this->agent->browser().' '.$this->agent->version();
echo '컴퓨터';
}
elseif ($this->agent->is_robot())
{
$agent = $this->agent->robot();
}
elseif ($this->agent->is_mobile())
{
$agent = $this->agent->mobile();
echo '핸드폰';
}
else
{
$agent = 'Unidentified User Agent';
}
echo $agent;
echo $this->agent->platform(); // Platform info (Windows, Linux, Mac, etc.)
}
}
?>
여기서 핸드폰으로 사이트를 들어가봣는데
컴퓨터Chrome 80.0.3987.132Windows 10
컴퓨터Chrome 80.0.3987.132Windows 10
이런식으로 출력이 되더군요.
왜그런지 전혀 모르겠습니다. ㅠㅠ
딱 핸드폰만 잡아내서 실행시키고싶은데..
application/config/user_agents.php 파일에 정의된 패턴대로 판정합니다.
정의되어 있지 않으면 원하는 결과가 안나옵니다.