输入中出现意外的字符:Silex应用程序中的'\'(ASCII = 92)状态= 1

时间:2012-10-29 15:49:03

标签: namespaces autoload silex php

我将我的网站从本地移动到托管,我发生了一些事情。我将此配置文件包含在我的index.php中(这是我做的第一件事):

<?php
require_once __DIR__.'/../../vendor/autoload.php';

// some other stuff

$app = new Silex\Application();
$app['debug'] = true;

$defaultLocale = 'en';

$app->register(new Silex\Provider\TwigServiceProvider(), array(
    'twig.path' => array(
                            __DIR__.'/../views', 
                            __DIR__.'/../views/backend', 
                            __DIR__.'/../views/layouts',
                            __DIR__.'/../views/components',
                            __DIR__.'/../views/backend/components', 
                        ),
));
$app->register(new Nicl\Silex\MarkdownServiceProvider());

但网站抱怨这样:

  

警告:输入中出现意外字符:'\'(ASCII = 92)状态= 1 in   第7行/public_html/_inc/config.php

     

解析错误:语法错误,意外的T_STRING   第7行/public_html/_inc/config.php

基本上,第7行​​是$app = new Silex\Application();。我正在使用Silex,服务器正在运行PHP 5.2。供应商文件夹(包含所有框架和第三方内容)位于root(/

我想知道它在自动加载方面有一些问题,但我找不到究竟是什么或如何测试它。你觉得有什么奇怪的吗?提前谢谢。

1 个答案:

答案 0 :(得分:20)

根据official documentation,Silex需要 PHP 5.3 来提供名称空间支持。
尝试将服务器迁移到PHP 5.3以消除此错误。

  

Silex是PHP 5.3的PHP微框架。

相关问题