Silex应用程序中输入的意外字符为'\'(ASCII = 92)state = 1 [英] Unexpected character in input: '\' (ASCII=92) state=1 in a Silex Application

查看:68
本文介绍了Silex应用程序中输入的意外字符为'\'(ASCII = 92)state = 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:

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

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

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

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

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

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.

推荐答案

根据官方文档,Silex需要 PHP 5.3 提供名称空间支持.
尝试将您的服务器迁移到PHP 5.3,以消除此错误.

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是用于PHP 5.3的PHP微框架.

Silex is a PHP microframework for PHP 5.3.

这篇关于Silex应用程序中输入的意外字符为'\'(ASCII = 92)state = 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆