Build a mobile website with ThinkPHP_PHP tutorial
The function is_mobile in the code comes from the Internet and is very well written. The entry file determines the terminal type and defines APP_PATH and APP_NAME to execute different groupings. The effect I want to achieve is that both PC and Mobile are accessed by top-level domain names. Of course, if you want to achieve access similar to wap.xxx.com on your mobile phone, this method cannot be done. This is a problem of thinkphp multi-domain deployment. Please refer to the TP manual for details.
It is very convenient to use the thinkphp framework to quickly develop a small site, just like this site. Caigen.com has also made a mobile website. Enter the website domain name www.icaigen.com into the mobile browser to view the effect.
The following only describes how to implement platform judgment in the index.php file of thinkphp's front-end guidance page to load different groups (or projects).
//判断是否属手机 function is_mobile(){ $user_agent = $_SERVER['HTTP_USER_AGENT']; $mobile_agents = Array("240x320","acer","acoon","acs-","abacho","ahong","airness","alcatel","amoi","android","anywhereyougo.com","applewebkit/525","applewebkit/532","asus","audio","au-mic","avantogo","becker","benq","bilbo","bird","blackberry","blazer","bleu","cdm-","compal","coolpad","danger","dbtel","dopod","elaine","eric","etouch","fly ","fly_","fly-","go.web","goodaccess","gradiente","grundig","haier","hedy","hitachi","htc","huawei","hutchison","inno","ipad","ipaq","ipod","jbrowser","kddi","kgt","kwc","lenovo","lg ","lg2","lg3","lg4","lg5","lg7","lg8","lg9","lg-","lge-","lge9","longcos","maemo","mercator","meridian","micromax","midp","mini","mitsu","mmm","mmp","mobi","mot-","moto","nec-","netfront","newgen","nexian","nf-browser","nintendo","nitro","nokia","nook","novarra","obigo","palm","panasonic","pantech","philips","phone","pg-","playstation","pocket","pt-","qc-","qtek","rover","sagem","sama","samu","sanyo","samsung","sch-","scooter","sec-","sendo","sgh-","sharp","siemens","sie-","softbank","sony","spice","sprint","spv","symbian","tablet","talkabout","tcl-","teleca","telit","tianyu","tim-","toshiba","tsm","up.browser","utec","utstar","verykool","virgin","vk-","voda","voxtel","vx","wap","wellco","wig browser","wii","windows ce","wireless","xda","xde","zte"); $is_mobile = false; foreach ($mobile_agents as $device) { if (stristr($user_agent, $device)) { $is_mobile = true; break; } } return $is_mobile; } define('THINK_PATH','./CORE/'); if(is_mobile()){ //跳转至wap分组 define('APP_NAME','Wap'); define('APP_PATH','./Wap/'); }else{ define('APP_NAME','Home'); define('APP_PATH','./Home/'); } define('APP_DEBUG', false); require THINK_PATH.'core.php';
The effect I want to achieve is that both PC and Mobile are accessed by top-level domain names. Of course, if you want to achieve access similar to wap.xxx.com on your mobile phone, this method cannot be done. This is a problem of thinkphp multi-domain deployment. Please refer to the TP manual for details.
After defining the entry file, you can develop the code for the mobile website under the WAP group (or project). Because it is a mobile version of the website, resolution, image compression, web page size, etc. are all naked issues. I have only been involved in mobile website construction for a few days, so I don’t show off anymore. What is clear is that non-main functions on the PC website can be cut off on the mobile website, such as popular blog articles, random articles, comment lists, various widgets, etc.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











According to news on August 17, the source @ibinguniverse posted on Weibo today, stating that the exact size of Apple iPhone 16 Pro Max is 6.88 inches, and the exact size of Galaxy S25 Ultra is 6.86 inches. Both can be regarded as 6.9 inches. Sources indicate that the Samsung Galaxy S25 Ultra has a narrower body and a wider screen than the S24 Ultra, with a horizontal screen-to-body ratio of 94.1%, while the S24 Ultra’s horizontal screen-to-body ratio is 91.5%. Fenye checked the relevant Weibo of the source. He also commented on the newly exposed photos of iPhone 16 Pro Max and believed that it was wrong to be close to a micro-curve. The phone is actually a straight screen + 2.5D glass.

Although Apple has been criticized for its lack of innovation in recent years, Apple has not always stood still. At least in terms of hardware design, with the support of the high unit prices of Apple products, its engineers can easily try some new technologies without having to consider too much cost issues. For example, iPad Pro, as Apple's favorite "display technology" test field, iPad Pro has been at the forefront of display technology for portable smart devices from miniLED in 2021 to tandem OLED in 2024. Although the iPad Pro is not the first portable smart device equipped with a miniLED screen (MSI released a miniLED laptop a year earlier than Apple), when you compare the parameters of the two, you will quickly realize that they are not the same

According to news on August 9, at the FMS2024 Summit, SK Hynix demonstrated its latest storage products, including UFS4.1 universal flash memory that has not yet officially released specifications. According to the official website of the JEDEC Solid State Technology Association, the latest UFS specification currently announced is UFS4.0 in August 2022. Its theoretical interface speed is as high as 46.4Gbps. It is expected that UFS4.1 will further improve the transmission rate. 1. Hynix demonstrated 512GB and 1TBUFS4.1 general-purpose flash memory products, based on 321-layer V91TbTLCNAND flash memory. SK Hynix also exhibited 3.2GbpsV92TbQLC and 3.6GbpsV9H1TbTLC particles. Hynix shows off V7-based

According to news on August 19, Nubia has been adhering to the true full-screen design since the release of Z50 Ultra, and has been continuously exploring the field of proactive photography under high-pixel screens. Today, digital blogger Wisdom Pikachu broke the news that the Nubia Z70 Ultra, which will be released in the second half of this year, will debut with 1.5K under-screen camera technology, which is the highest-resolution UDC solution in the industry so far. It is reported that ZTE’s under-screen proactive solution has advanced to the sixth generation. The latest under-screen proactive solution is available in the Nubia Z60 Ultra and Red Magic 9S Pro series. The screen resolution is 2480x1116, which is between 1080P and 1.5K resolution. This time Nubia will break through the limitations of existing resolutions and set a new benchmark in the industry.

According to a report from Smartprix, Xiaomi is developing a buttonless mobile phone codenamed "Suzaku". According to this news, this mobile phone codenamed Zhuque will be designed with an integrated concept, use an under-screen camera, and be equipped with Qualcomm Snapdragon 8gen4 processor. If the plan does not change, we are likely to see its arrival in 2025. When I saw this news, I thought I was back in 2019 - at that time, Xiaomi released the Mi MIX Alpha concept phone, and the surround-screen button-less design was quite amazing. This is the first time I have seen the charm of a buttonless mobile phone. If you want a piece of "magic glass", you must first kill the buttons. In "The Biography of Steve Jobs", Jobs once expressed that he hoped that the mobile phone could be like a piece of "magic glass".

According to news on August 8, the detailed configuration information of Huawei Mate70 series mobile phones has been recently exposed. This series of mobile phones is expected to be released in the fourth quarter of 2024. 1. According to reports, the entire Mate70 series will use customized top-level 1.5K resolution screens to meet users’ requirements for screen clarity. It is expected that Huawei Mate70Pro and the extra-large cup version will be equipped with fourth-depth screens, while the standard Mate70 may adopt a slightly smaller straight-screen design. In addition to screen upgrades, the Huawei Mate70 series will also be equipped with ultra-large-capacity batteries with new base materials, which heralds a breakthrough in the battery life of Huawei Mate series mobile phones. Although Huawei is developing ultrasonic fingerprint unlocking technology, this year’s Mate70 series will not be equipped with this feature. this

According to overseas media reports, Transsion, a Chinese mobile phone manufacturer ranked among the top five in global mobile phone sales, has released a smartphone developed in cooperation with BMW (BMW) - the Infinix Note 40 series racing version. Currently, the InfinixNote40 series racing version offers two models, namely InfinixNote40Pro5G and InfinixNote40Pro+5G. Unfortunately, there is almost no possibility of these models landing in the Chinese market. It is understood that the appearance of the InfinixNote40 series racing version is inspired by BMW. The back panel adopts the three-color BMW MPower logo. There are also customized wallpapers and icons inside the phone. The whole machine has a lot of BMW elements. Configuration processing

According to news on August 24, technology media 91Mobile published a blog post yesterday (August 23), breaking the news that Xiaomi will release the Redmi14C smartphone on August 31, which will be available in three colors: green (should be plain leather), black and blue. Xiaomi Redmi14C is equipped with an Oreo circular camera module on the back, equipped with 2 camera sensors and 1 LED flash, 50-megapixel main camera, and the volume and power buttons are on the right side. Attached is the promotional picture of Xiaomi Redmi14C as follows. You can see that the front is equipped with a water drop-shaped groove. Since the product is positioned at the mid-to-low end, the frame on the chin part is wider. In terms of specifications, Xiaomi Redmi14C mobile phone is equipped with a 6.88-inch FullHD+ resolution screen with a refresh rate of 90H
