+ -
当前位置:首页 → 问答吧 → 关闭了调试模式 网站提示错误

关闭了调试模式 网站提示错误

时间:2011-03-27

来源:互联网

'APP_DEBUG' =>  true ,  的时候访问正常
false 之后就显示:
Parse error: syntax error, unexpected T_STRING in D:\wamp\www\ts\Runtime\~app.php on line 1
我删除了~app.php之后可以打开了,但是刷新一次又产生这个文件,又无法打开了

到底是怎么回事呢?

作者: cjsnet   发布时间: 2011-03-27

调试模式下不会生成~app.php,不调试时为了效率就把项目下的一个配置文件,函数等弄成一个文件了~app.php,而会去掉多余的空格注释什么的,变成只有一行。
   你先打开~app.php,看看到底是哪个地方的符号写错了,把他改对试试。
   再看看下面代码导入的文件,要修改对应的原文件,才能保证下次生成~app.php时不会再次出错
  1. static private function build()
  2.     {
  3.         // 加载惯例配置文件
  4.         C(include THINK_PATH.'/Common/convention.php');
  5.         // 加载项目配置文件
  6.         if(is_file(CONFIG_PATH.'config.php'))
  7.             C(include CONFIG_PATH.'config.php');

  8.         $runtime = defined('RUNTIME_ALLINONE');
  9.         $common   = '';
  10.          //是否调试模式 ALL_IN_ONE模式下面调试模式无效
  11.         $debug  =  C('APP_DEBUG') && !$runtime;
  12.         // 加载项目公共文件
  13.         if(is_file(COMMON_PATH.'common.php')) {
  14.             include COMMON_PATH.'common.php';
  15.             // 编译文件
  16.             if(!$debug)
  17.                 $common   .= compile(COMMON_PATH.'common.php',$runtime);
  18.         }
  19.         // 加载项目编译文件列表
  20.         if(is_file(CONFIG_PATH.'app.php')) {
  21.             $list   =  include CONFIG_PATH.'app.php';
  22.             foreach ($list as $file){
  23.                 // 加载并编译文件
  24.                 require $file;
  25.                 if(!$debug) $common   .= compile($file,$runtime);
  26.             }
  27.         }
  28.         // 读取扩展配置文件
  29.         $list = C('APP_CONFIG_LIST');
  30.         foreach ($list as $val){
  31.             if(is_file(CONFIG_PATH.$val.'.php'))
  32.                 C('_'.$val.'_',array_change_key_case(include CONFIG_PATH.$val.'.php'));
  33.         }
  34.         // 如果是调试模式加载调试模式配置文件
  35.         if($debug) {
  36.             // 加载系统默认的开发模式配置文件
  37.             C(include THINK_PATH.'/Common/debug.php');
  38.             if(is_file(CONFIG_PATH.'debug.php'))
  39.                 // 允许项目增加开发模式配置定义
  40.                 C(include CONFIG_PATH.'debug.php');
  41.         }else{
  42.             // 部署模式下面生成编译文件
  43.             // 下次直接加载项目编译文件
  44.             if($runtime) {
  45.                 // 获取用户自定义变量
  46.                 $defs = get_defined_constants(TRUE);
  47.                 $content  = array_define($defs['user']);
  48.                 $content .= substr(file_get_contents(RUNTIME_PATH.'~runtime.php'),5);
  49.                 $content .= $common."\nreturn ".var_export(C(),true).';';
  50.                 file_put_contents(RUNTIME_PATH.'~allinone.php',strip_whitespace('<?php '.$content));
  51.             }else{
  52.                 $content  = "<?php ".$common."\nreturn ".var_export(C(),true).";\n?>";
  53.                 file_put_contents(RUNTIME_PATH.'~'.APP_CACHE_NAME.'.php',strip_whitespace($content));
  54.             }
  55.         }
  56.         return ;
  57. }
复制代码

作者: ceywj   发布时间: 2011-03-27

我估计是某个函数写漏了符号而尔common.php的机率比较大,但具体是哪个只能自己去找了。

作者: ceywj   发布时间: 2011-03-27

太感谢了!解决了,就是common.php里一个变量我用的双引号出的问题!

作者: cjsnet   发布时间: 2011-03-27