简体   繁体   English

如何编码(base64)和解码(base64)多个通过php中的url传递的变量

[英]How to encode (base64) and decode(base64) more than one variable which is passing via url in php

I want to pass more than one variable via url. 我想通过网址传递多个变量。 I do not want to show those values to the user.Therefore while passing the variable via url I encode the by base64 and in another file I decode it and I will use. 我不想向用户显示这些值,因此在通过url传递变量时,我通过base64编码了编码,并在另一个文件中对其进行了解码并将使用。 I am able to do this for one variable.But, I want to implement the same for more than one variable. 我可以为一个变量执行此操作,但是我想为多个变量实现相同的操作。 I am not getting how to do this. 我没有怎么做。

Can anyone assist me? 谁能帮助我?

My code is, 我的代码是

encode.php encode.php

<?php
    $link = "decrypt.php?item=".urlencode(base64_encode('testing'))."";
    echo '<a href='.$link.'>click here</a>';
?>

decode.php decode.php

<?php
    foreach($_GET as $loc=>$item)
       $_GET[$loc] = base64_decode(urldecode($item));
       echo $_GET[$loc];
?>

But, I should pass more than one like 但是,我应该通过多个

<a href="test.php?name="Suma"&place="India"">click</a>

How do I do this? 我该怎么做呢?

I got answer:) 我得到了答案:)

I have like this, 我有这样

My code is, 我的代码是

encode.php encode.php

<?php
    $link = "decrypt.php? 
   item=".urlencode(base64_encode('testing'))."&rate=".urlencode(base64_encode('10'))."";
echo '<a href='.$link.'>click here</a>';
?>

decode.php decode.php

<?php
    echo base64_decode(urldecode($_GET['item']));
    echo base64_decode(urldecode($_GET['rate']));
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM