我一直在用一些破碎的代碼拉我的頭髮。我提前發佈了一個問題,但是我已經將問題縮小到了具體問題。在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