Ubuntu筆記本和小米手機都連上小米路由.
php -S 0.0.0.0:8080 -t ./
若是沒有無線路由,能夠在Ubuntu筆記本上用hostapd創建無線網絡:
http://my.oschina.net/eechen/blog/227230 開放8080端口: sudo ufw allow 8080/tcp && sudo ufw status 禁用8080端口: sudo ufw delete allow 8080/tcp ifconfig wlan0 查看Ubuntu的IP爲 192.168.31.156 掃描二維碼或者輸入地址訪問網頁: qrencode -o mi.png http://192.168.31.156:8080 能夠從PHP CLI Server的控制檯看到手機的IP地址. 手機在鎖屏後輪詢的AJAX請求會被暫停. 查看手機瀏覽器User Agent: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>User Agent</title> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"> </head> <body> <?php $ua = $_SERVER['HTTP_USER_AGENT']; file_put_contents('ua.log', $ua); error_log($ua); //記錄在error_log="/png/php/php_errors.log" echo $ua; ?> </body> 附: 小米4 MIUI 7 瀏覽器: Mozilla/5.0 (Linux; U; Android 4.4.4; zh-cn; MI 4LTE Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/42.0.0.0 Mobile Safari/537.36 XiaoMi/MiuiBrowser/2.1.1 小米4上的UC瀏覽器: Mozilla/5.0 (Linux; U; Android 4.4.4; zh-CN; MI 4LTE Build/KTU84P) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.8.0.654 U3/0.8.0 Mobile Safari/534.30 三星S4 瀏覽器: Mozilla/5.0 (Linux; Android 4.2.2; GT-I9505 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36 iPhone 6 瀏覽器: Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4