我一直在用一些破碎的代码拉我的头发。我提前发布了一个问题,但是我已经将问题缩小到了具体问题。在PHP中使用base64_decode()后无法读取字符串变量
前面的问题:Can't assess an array element after building array - a var_dump confirms element is there
现在的问题是与以base64解码功能。它的意思是返回一个字符串,但是当你试图读取字符串时,它不起作用。
参见这个简单的测试代码...
的error_reporting(E_ALL);
$encoded = base64_encode('my encrypted text');
$decoded = base64_decode($encoded, true);
echo "<br />";
printf('my encrypted text -> encoded to base64 = %s', $encoded);
echo "<br />";
printf('%s from base64 = %s', $endcoded, $decoded);
echo "<br />";
printf('calling $decoded to read string: result = %s', $decoded);
下面是结果
my encrypted text -> encoded to base64 = bXkgZW5jcnlwdGVkIHRleHQ=
Notice: Undefined variable: endcoded in /home/website/base64test.php on line 10
from base64 = my encrypted text
calling $decoded to read string: result = my encrypted text
10号线是这样的:
printf('%s from base64 = %s', $endcoded, $decoded);
这是一个错误?或者我错过了什么。
你打算如何在base64_decode()函数存储在变量中后读取结果?
'S/endcoded/encoded' – Phil