Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 520
Sergi Juanola Avatar asked Oct 29 '12 15:10

Sergi Juanola


1 Answers

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.

like image 116
Florent Avatar answered Oct 15 '22 20:10

Florent