相关疑难解决方法(0)

如何删除多个UTF-8 BOM序列

使用PHP5(cgi)从文件系统输出模板文件,并且有问题吐出原始HTML.

private function fetch($name) {
    $path = $this->j->config['template_path'] . $name . '.html';
    if (!file_exists($path)) {
        dbgerror('Could not find the template "' . $name . '" in ' . $path);
    }
    $f = fopen($path, 'r');
    $t = fread($f, filesize($path));
    fclose($f);
    if (substr($t, 0, 3) == b'\xef\xbb\xbf') {
        $t = substr($t, 3);
    }
    return $t;
}
Run Code Online (Sandbox Code Playgroud)

即使我已经添加了BOM修复程序,我仍然遇到Firefox接受它的问题.你可以在这里看到一个实时的副本:http://ircb.in/jisti/(如果你想查看它,我在http://ircb.in/jisti/home.html投掷的模板文件)

知道如何解决这个问题吗?O_O

php byte-order-mark utf-8

50
推荐指数
6
解决办法
7万
查看次数

PHP AES加密/解密

我在PHP中找到了en/decode字符串的示例.起初它看起来非常好,但它不会工作:-(

有谁知道问题是什么?

$Pass = "Passwort";
$Clear = "Klartext";

$crypted = fnEncrypt($Clear, $Pass);
echo "Encrypted: ".$crypted."</br>";

$newClear = fnDecrypt($crypted, $Pass);
echo "Decrypted: ".$newClear."</br>";

function fnEncrypt($sValue, $sSecretKey) {
    return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, $sDecrypted, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
}

function fnDecrypt($sValue, $sSecretKey) {
    return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sSecretKey, base64_decode($sEncrypted), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)));
}
Run Code Online (Sandbox Code Playgroud)

结果是:

加密: boKRNTYYNp7AiOvY1CidqsAn9wX4ufz/D9XrpjAOPk8=

解密: —‚(ÑÁ ^ yË~F'¸®Ó–í œð2Á_B‰Â—

php encryption cryptography aes encryption-symmetric

46
推荐指数
6
解决办法
20万
查看次数