Home  >  Article  >  Backend Development  >  How to determine whether php is mobile or pc

How to determine whether php is mobile or pc

藏色散人
藏色散人Original
2022-11-09 09:12:372481browse

php method to determine whether it is mobile or PC: 1. Create a php sample file; 2. Define the function as "function is_Mobile(){if (isset($_SERVER['HTTP_VIA']) && stristr( $_SERVER['HTTP_VIA'], "wap")) {return true;}..."; 3. Just call the function.

How to determine whether php is mobile or pc

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

How to determine whether PHP is mobile or PC?

php determines whether the user is PC or mobile

Code implementation

1. Define function

2 . Function call

- Called in the same file

Called when it is necessary to determine whether the user is a mobile or PC client

- Called in different files

At the beginning, use "require_once()" to reference the PHP code module containing the function in 1, and call it when you need to determine whether the user is a mobile terminal or a PC terminal.

Recommended learning: "PHP Video Tutorial

The above is the detailed content of How to determine whether php is mobile or pc. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn