1. 程式人生 > >Thinkphp3.2.3驗證碼無法顯示解決方法

Thinkphp3.2.3驗證碼無法顯示解決方法

function 驗證碼 public verify 信息

方法1

 public    function verify(){
        ob_clean();//清除BOM信息
        $Verify = new \Think\Verify();
        $Verify->entry();
    }

方法2

<?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")." <br>";  
    }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 ("<font color=red>BOM found, automatically removed.</font>");  
  } else {  
   return ("<font color=red>BOM found.</font>");  
  }  
}  
else return ("BOM Not Found.");  
}  
function rewrite ($filename, $data) {  
$filenum = fopen($filename, "w");  
flock($filenum, LOCK_EX);  
fwrite($filenum, $data);  
fclose($filenum);  
}  
?>

根目錄保存文件執行,即可清除BOM




本文出自 “無名人” 博客,請務必保留此出處http://wmname.blog.51cto.com/8780640/1930424

Thinkphp3.2.3驗證碼無法顯示解決方法