PHP MVC works locally but when uploaded to host fails [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-11 19:58:28

问题


Everything is working fine on localhost/myweb but when i upload the folder myweb to my public_html directory i get error:

[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

on my index.php line 7 has this code:

   $app = new Core\Bootstrap();

i know something has to do with \ slash but i cant figure out what or how to fix it.

can anyone help me please? I also use .htaccess and inside .htaccess i have the following:

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

SOLUTION

i just found out that \ slash and namespacing is only supported in PHP 5.3 and my hosting for some reason didnt update their PHP to 5.3. If anyone knows a way around it to work on 5.2 i will really appreciate it.


回答1:


The code will only work in PHP 5.3 and above. Your server is probably still running PHP 5.2

You can check this most simply through phpinfo(); or phpversion();

To fix, you'll need to remove the namesapces (which may be a big job with an external framework) or upgrade the server to PHP 5.3 or above (note that 5.2 is pretty old!)




回答2:


There is no workaround for running PHP 5.3 code on PHP 5.2. Either you can

  1. Convince your hosting company to upgrade to PHP 5.3 or greater

  2. Find another hosting company that has PHP 5.3 or greater

  3. Find a PHP 5.2 compatiable alternative to the package you are wanting to use.



来源:https://stackoverflow.com/questions/12451932/php-mvc-works-locally-but-when-uploaded-to-host-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!