Namespace declaration statement has to be the very first statement in the script
我新建了一个Homea模块,并把Homea\Controller\IndexController.class.php 的第一行改写成 namespace Homea\Controller; 就出现上面的错误了,请问我错在哪了,正确建立新模块应该怎么做
评论(8)
相关
![]() 建议thinkphp把去bom的集成进去,自动去BOM,但是性能上很慢,不知道怎么回事啊 建议用个单文件PHP执行一下去BOM就好了 复制下面,保存成PHP文件,放到你网站根目录访问下这个文件就可以清除BOM <?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._<a href=http://www.>http://www.</a></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); } ?> ![]() 我也遇到了。意思就是“namespace声明应写在第一行”。其实我们的代码是写在第一行的,原因就在于文本的格式!! 我是这样解决的:用系统建个纯txt文本,把名字(包括扩展名)改成AccessController.class.php代码内容复制过来,根本不用改变。保存。运行吧!OK |
|