[정보] 접속 환경(PC or Mobile)을 구분해주는 PHP 함수
This post was written on February 23, 2023

PC 환경에서 접속한 것인지 모바일 환경에서 접속한 것인지 알아내는 PHP 함수이다. 많이 사용하는 함수이다.

  • chatGPT가 만들어 준 함수이다.
  function get_device_type() {
      $user_agent = $_SERVER['HTTP_USER_AGENT'];
      $mobile_agents = array('iphone','ipod','ipad','android','webos',
      'blackberry','nokia','opera mini','windows mobile','windows phone','iemobile');
      foreach($mobile_agents as $mobile_agent) {
          if (strpos(strtolower($user_agent), strtolower($mobile_agent)) !== false) {
              return 'mobile';
          }
      }
      return 'PC';
  }


HS LOG List of ETC

Copyright © HS LOG
Published on February 23, 2023 Filed under: ETC; Tagged as: , , , ,

No Comments

Thank you for visiting. If you leave a comment, I will not forget.

HS LOG List of ETC

 
The number of visitors for this post is 394 (measured by Jetpack).