本篇文章給大家?guī)砹岁P(guān)于PHP的相關(guān)知識(shí),其中主要介紹了PHP怎么檢測(cè)IP相關(guān)信息的,以及PHP如何獲取HTTP、vue包等,感興趣的朋友,下面一起來看一下吧,希望對(duì)大家有幫助。
-
PHP檢測(cè)IP是否內(nèi)網(wǎng)地址、保留地址
/** * @param string $ip 被檢測(cè)的IP * @return bool 是否內(nèi)網(wǎng)或者保留IP */ public function isInternalIp($ip) { $ip = ip2long($ip); if (!$ip) { //非法IP,直接算true吧 return true; } $net_a = ip2long('10.255.255.255') >> 24; //A類網(wǎng)預(yù)留ip的網(wǎng)絡(luò)地 $net_b = ip2long('172.31.255.255') >> 20; //B類網(wǎng)預(yù)留ip的網(wǎng)絡(luò)地址 $net_c = ip2long('192.168.255.255') >> 16; //C類網(wǎng)預(yù)留ip的網(wǎng)絡(luò)地址 $net_local127 = ip2long('127.255.255.255') >> 24; //127保留地址 $net_local169 = ip2long('169.254.255.255') >> 16; //169保留地址 return $ip >> 24 === $net_a || $ip >> 20 === $net_b || $ip >> 16 === $net_c || $net_local127 === $ip >> 24 || $net_local169 === $ip >> 16; }
登錄后復(fù)制
這個(gè)是我網(wǎng)上找來的,具體地址我忘了,然后自己加了保留地址的檢測(cè)
-
PHP獲取HTTP包流量整個(gè)HTTP請(qǐng)求包流量
public function http() { $row = $_SERVER['REQUEST_URI'] . "rr"; $header = getallheaders(); foreach ($header as $k => $v) { $row .= $k . ': ' . $v . "r"; } $row .= "rr" . file_get_contents("php://input"); return $row; }
登錄后復(fù)制
-
vue差量更新包-PHP處理
public function test() { $config = json_decode(file_get_contents('vueconfig.json'), true); //配置目錄,初次使用要先建立配置 $path = 'D:\web\project\vue\dist\static\'; // 打包的靜態(tài)地址 foreach ($config as $dir => $type) { foreach (scandir($path . $dir) as $fkey => $fva) { if ($fva == '.' || $fva == '..') { continue; } else { if (in_array($fva, $type)) { //沒有更新就刪除該文件 unlink($path . $dir . '\' . $fva); } else { echo '新增文件:' . $path . $dir . '\' . $fva . "<br>"; //有更新就把新文件加入到配置表里記錄 $config[$dir][$fkey] = $fva; } } } } //更新配置表 file_put_contents('vueconfig.json', json_encode($config)); }
登錄后復(fù)制
直接運(yùn)行即可刪除沒有改變的文件,保留更新的文件,實(shí)現(xiàn)差量更新
推薦學(xué)習(xí):《PHP視頻教程》