PHP MVC在本地工作,但上载到主机时失败

PHP MVC在本地工作,但上载到主机时失败,php,localhost,syntax-error,Php,Localhost,Syntax Error,在localhost/myweb上一切正常,但当我将文件夹myweb上载到我的public\u html目录时,出现错误: [16-Sep-2012 18:32:55] PHP Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home1/programw/public_html/myweb/index.php on line 7 [16-Sep-2012 18:32:55] PHP Parse err

在localhost/myweb上一切正常,但当我将文件夹myweb上载到我的public\u html目录时,出现错误:

[16-Sep-2012 18:32:55] PHP Warning:  Unexpected character in input:  '\' (ASCII=92)  
state=1 in /home1/programw/public_html/myweb/index.php on line 7

[16-Sep-2012 18:32:55] PHP Parse error:  syntax error, unexpected T_STRING in /home1
/programw/public_html/myweb/index.php on line 7
在my index.php第7行中有以下代码:

   $app = new Core\Bootstrap();
我知道与\slash有关,但我不知道如何修复它

有人能帮我吗?我还使用.htaccess和inside.htaccess。我有以下几点:

   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
解决方案


我刚刚发现\slash和名称空间仅在PHP5.3中受支持,我的主机由于某种原因没有将它们的PHP更新为5.3。如果有人知道如何使用5.2,我将非常感激。

该代码只适用于PHP5.3及以上版本。您的服务器可能仍在运行PHP5.2

您可以通过phpinfo()最简单地检查这一点;或phpversion()


要解决这个问题,您需要删除namesapces(对于外部框架来说,这可能是一项艰巨的工作),或者将服务器升级到PHP5.3或更高版本(注意,5.2已经非常旧了!)

在PHP5.2上运行PHP5.3代码没有解决办法。要么你可以

  • 说服您的托管公司升级到PHP5.3或更高版本

  • 找到另一家拥有PHP5.3或更高版本的托管公司

  • 找到一个PHP5.2兼容的替代程序包来替代您想要使用的程序包