天天看點

php驗證碼顯示亂碼,php模闆設計模式ThinkPHP打開驗證碼頁面顯示亂碼的解決方法...

本文執行個體講述了ThinkPHP打開驗證碼頁面顯示亂碼的解決方法。分享給大家供大家參考。具體分析如下:

在用thinkphp開發的時候,有時會出現驗證碼亂碼的問題,解決方法是把如下這個檔案放在根目錄,通路後就可以解決了,具體的PHP代碼如下:

電腦技術網認為此文章對《php模闆設計模式ThinkPHP打開驗證碼頁面顯示亂碼的解決方法》說的很在理。<?php

if (isset($_GET['dir'])){ //設定檔案目錄

$basedir=$_GET['dir'];

}else{

$basedir = '.';

}

$auto = 1;

checkdir($basedir);

function checkdir($basedir){

if ($dh = opendir($basedir)) {

while (($file = readdir($dh)) !== false) {

if ($file != '.' && $file != '..'){

if (!is_dir($basedir."/".$file)) {

echo "filename: $basedir/$file ".checkBOM("$basedir/$file")."

";

}else{

$dirname = $basedir."/".$file;

checkdir($dirname);

}

}

}

closedir($dh);

}

}

function checkBOM ($filename) {

global $auto;

$contents = file_get_contents($filename);

$charset[1] = substr($contents, 0, 1);

$charset[2] = substr($contents, 1, 1);

$charset[3] = substr($contents, 2, 1);

if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {

if ($auto == 1) {

$rest = substr($contents, 3);

rewrite ($filename, $rest);

return ("BOM found, automatically removed.");

} else {

return ("BOM found.");

}

}

else return ("BOM Not Found.");

}

function rewrite ($filename, $data) {

$filenum = fopen($filename, "w");

flock($filenum, LOCK_EX);

fwrite($filenum, $data);

fclose($filenum);

}

?>希望本文所述對大家基于ThinkPHP架構的PHP程式設計有所幫助。

更多:php模闆設計模式ThinkPHP打開驗證碼頁面顯示亂碼的解決方法

https://www.002pc.comhttps://www.002pc.com/phpbiancheng/2429.html

你可能感興趣的亂碼,ThinkPHP,驗證碼,頁面,打開,解決

No alive nodes found in your cluster

0踩

0 贊