home page Site building tutorial Zblog website establishment text

ZblogPHP judges whether it is a mobile terminal

The following code can be used to add access device judgment for the website, and allow the website to call different modules or interface effects for different access devices, such as advertisements, banners, etc. function APPID_is_mobile() { if ( empty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; } elseif ( st...

The following code can be used to add access device judgment for the website, and allow the website to call different modules or interface effects for different access devices, such as advertisements, banners, etc.

 function APPID_is_mobile() { if (  em pty($_SERVER['HTTP_USER_AGENT']) ) { $is_mobile = false; } elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !==  false // many mobile devices (all  ip hone,  iPad, etc.)  strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !==  false  strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !==  false  strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !==  false  strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !==  false  strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !==  false  strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !==  false ) { $is_mobile = true; } else { $is_mobile = false; } 	return $is_mobile;}



Save the above functions to theme include.php stay Template The following methods are used in the file

 {if umqya_is_mobile()} Mobile terminal  {else} PC side {/if}


Reward
poster

Statement: Some of the resources on this site are original works on the site, and some are publicly shared and collated based on the Internet. The copyright belongs to the original author.
If it infringes your rights, please contact our website, and we will deal with it as soon as possible. Thank you. Please indicate the source of the transfer

Link to this article: https://www.umtheme.com/zblog/61.html

Related recommendations

 The list of zblog custom categories is sorted by browsing volume, comments, update time, ID or author

The list of zblog custom categories is sorted by browsing volume, comments, update time, ID or author

ZBLOG provides rich interfaces to facilitate the personalized customization of webmasters, so it is easy to reorder articles. For example, it may be necessary to adjust the default sorting of the system during the development and production process (the latest one is first), so that the list of articles under a certain category on its website is based on the specified (browse volume
Zblog website establishment 2022.10.16 zero three thousand and sixty-one
Post comments

Thank you for your support