我正在做一个如何使用PHP编码函数从编码数据中获取实际数据的测试。一旦我编码,我无法获得原始数据。相反,我得到一些特殊的字符Unicode ...如何从解码后的数据解码后得到数据?
我的代码如下。
$key = '28e336ac6c9423d946ba02d19c6a2632'; // Randomly generated key
$request_params = array(
'controller' => 'mylist',
'action' => 'read',
'username' => 'test',
'password' => '12345'
));
$enc_request = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, json_encode($request_params), MCRYPT_MODE_ECB));
//echo $enc_request;exit; // Here I am getting the encoded string.
$paramas = base64_decode(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, json_decode($enc_request), MCRYPT_MODE_ECB)));
print_r($paramas); // Here I am getting like ... ºÇ
echo $paramas->controller; // Got nothing.
我在做什么错了?
解析错误:语法错误,意外“)”在尖沙咀。 php 8行 – RiggsFolly
修复:那么:'注意:尝试获取第14行tst.php中的非对象的属性' – RiggsFolly
当我只尝试var_dump($ paramas);它得到我...字符串(3)“ºÇ”... –