温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用php怎么对URL进行加密解密操作

发布时间:2021-01-30 18:36:54 来源:亿速云 阅读:235 作者:Leah 栏目:开发技术

使用php怎么对URL进行加密解密操作?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

具体如下:

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta http-equiv="content-language" content="zh-CN" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="MSThemeCompatible" content="Yes" />
<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="widow-target" content="_top" />
<meta name="robots" content="index, follow" />
<meta name="author" content="3945, [email]ljm77@km169.net[/email]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="copyright" content="Copyright 3945 All Rights Reserved" />
<title>无标题文档</title>
<style type="text/css">
<!--
a, a:link{text-decoration: none; color:#000000; font-size:9pt;}   a:visited{text-decoration: none; color:#000000;}   a:hover{text-decoration: underline; color:red;}
body, td, p, li, div, select{font-size:9pt; font-family:"宋体";}
-->
</style>
</head>
<body>
<?php
function query_encode($sQuery)
{//加密链接
  if(strlen($sQuery)==0)
   {
     return '';
   }
   else
   {
    $s_tem = preg_replace("/&/i", '&', $sQuery);
    $s_tem = preg_replace("/&/i", '&', $s_tem);
    $a_tem = explode('&', $s_tem);
    shuffle($a_tem);
    $s_tem = implode('&', $a_tem);
    $s_tem = rawurlencode($s_tem);
    $s_tem = base64_encode($s_tem);
    $s_tem = strrev($s_tem);
     return $s_tem;
   }
}
function query_decode($sEncode)
{//解密链接
  if(strlen($sEncode)==0)
   {
     return '';
   }
   else
   {
    $s_tem = strrev($sEncode);
    $s_tem = base64_decode($s_tem);
    $s_tem = rawurldecode($s_tem);
     return $s_tem;
   }
}
function rebuild_GET()
{//重写$_GET全局变量
  $_GET = array();
  $s_query = $_SERVER['QUERY_STRING'];
   if(strlen($s_query)==0)
   {
     return;
   }
   else
   {
    $s_tem = query_decode($s_query);
    $a_tem = explode('&', $s_tem);
     foreach($a_tem as $val)
     {
      $tem = explode('=', $val);
      $_GET[$tem[0]] = $tem[1];
     }
   }
}
rebuild_GET();
echo 'GET:<pre>'.print_r($_GET, true).'</pre>';
function testGET()
{
   echo 'Function GET:<pre>'.print_r($_GET, true).'</pre>';
}
testGET();
?>
<br /><br /><br />
<?
for($i=1; $i<10; $i++)
{
  $s_url = query_encode('ac=index:logo& >.$i);
   echo sprintf('<a href="?%s">TEST: %s</a><br />', $s_url, $s_url);
}
?>
</body>
</html>

看完上述内容,你们掌握使用php怎么对URL进行加密解密操作的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI