Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application

非 Y 不嫁゛ 提交于 2019-11-30 16:42:59

问题


I moved my website from local to a hosting, and something happened to me. I include this config file into my index.php (it's the first thing I do):

<?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());

But the website complains this way:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /public_html/_inc/config.php on line 7

Parse error: syntax error, unexpected T_STRING in /public_html/_inc/config.php on line 7

Basically, line 7 is $app = new Silex\Application();. I'm using Silex and the server is running PHP 5.2. The vendor folder (which contains all the framework and third parties stuff) is in root (/)

I was wondering it had some problems with autoload, but I don't find what could exactly be or how to test it. Do you find anything strange? Thanks in advance.


回答1:


According to the official documentation, Silex requires PHP 5.3 to provide namespace support.
Try to migrate your server to PHP 5.3 in order to get rid of this error.

Silex is a PHP microframework for PHP 5.3.



来源:https://stackoverflow.com/questions/13125007/unexpected-character-in-input-ascii-92-state-1-in-a-silex-application

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