php 输入中的意外字符:Silex 应用程序中的 '\' (ASCII=92) state=1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13125007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application
提问by Korcholis
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):
我将我的网站从本地转移到托管,然后发生了一些事情。我将此配置文件包含在我的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());
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
警告:输入中出现意外字符:第 7 行 /public_html/_inc/config.php 中的 '\' (ASCII=92) state=1
解析错误:语法错误,第 7 行 /public_html/_inc/config.php 中的意外 T_STRING
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 (/)
基本上,第 7 行是$app = new Silex\Application();. 我正在使用 Silex,服务器运行的是 PHP 5.2。供应商文件夹(包含所有框架和第三方内容)位于根目录 ( /)
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.
我想知道它在自动加载方面有一些问题,但我没有找到可能是什么或如何测试它。你觉得有什么奇怪的吗?提前致谢。
回答by Florent
According to the official documentation, Silex requires PHP 5.3to provide namespace support.
Try to migrate your server to PHP 5.3 in order to get rid of this error.
根据官方文档,Silex 需要PHP 5.3才能提供命名空间支持。
尝试将您的服务器迁移到 PHP 5.3 以消除此错误。
Silex is a PHP microframework for PHP 5.3.
Silex 是 PHP 5.3 的 PHP 微框架。

