在 PHP 中检测 base64 编码?


要在 PHP 中检测 base64 编码,如下面的代码所示 −

示例

 实时演示

<?php
$value_1 = array();
foreach (str_split('az019AZ~~~!@#$%^*()_+|}?><": Iñtërnâtiônàlizætiøn') as $char) {
   echo ord($char) . "n";
   $value_1[] = ord($char);
}
echo "Max value value_1 = " . max($value_1) . "
"; $value_2 = array(); echo "nnbase64:n"; foreach (str_split(base64_decode('Not base64 encoded',true)) as $char) {    echo ord($char) . "n";    $value_2[] = ord($char); } echo "Max value_2 = " . max($value_2) . "
"; ?>

输出

将产生以下输出 −

97n122n48n49n57n65n90n126n126n126n33n64n35n36n37n94n42n40n41n95n43n124n125n63n62n60n34n58n32n73n195n177n116n195n171n114n110n195n162n116n105n195n180n110n195n160n108n105n122n195n166n116n105n195n184n110nMax value value_1 = 195 nnbase64:n54n139n91n106n199n186n225n233n220n161n215n157nMax value_2 = 233

更新于: 09-04-2020

554 次浏览

开启你的 职业

完成课程以获得认证

开始
广告