语法错误,意外的“sidebar_bann"(T_ENCAPSED_AND_WHITESPACE),在使用 MongoDB ODM 和 ZF2 时需要“]" [英] syntax error, unexpected ''sidebar_bann' (T_ENCAPSED_AND_WHITESPACE), expecting ']' when working with MongoDB ODM and ZF2

查看:35
本文介绍了语法错误,意外的“sidebar_bann"(T_ENCAPSED_AND_WHITESPACE),在使用 MongoDB ODM 和 ZF2 时需要“]"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 MongoDB 和 Doctrine 2 ODM 的 ZF2,我在 New Relic 上遇到了上述错误(New relic 不断检查实时环境并记录错误).我收到以下错误:

I'm working with ZF2 with MongoDB and Doctrine 2 ODM, I got the above mentioned error on New Relic (New relic is continuously checking the live environment and logging the errors). I got the following error:

syntax error, unexpected ''sidebar_bann' (T_ENCAPSED_AND_WHITESPACE), expecting ']'
TracedError reported from New Relic
Timestamp: 02/26/14 10:49:15
Exception Class: E_PARSE
Error Action: /index.php
Uri: /blog
Error message
E_PARSE: syntax error, unexpected ''sidebar_bann' (T_ENCAPSED_AND_WHITESPACE), expecting ']'

并且堆栈跟踪指向:

…dor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/
HydratorFactory.php (144)
…dor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/
in Doctrine\ODM\MongoDB\Hydrator\HydratorFactory::getHydratorFor called at /vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Hydrator/HydratorFactory.php
HydratorFactory.php (404)
/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/
UnitOfWork.php (2518)
/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/
Cursor.php (118)
in Doctrine\ODM\MongoDB\Cursor::current called at ? 
…alled at /vendor/doctrine/mongodb/lib/Doctrine/MongoDB/
Cursor.php (371)
…alled at /vendor/doctrine/mongodb/lib/Doctrine/MongoDB/
Cursor.php (419)
…alled at /vendor/doctrine/mongodb/lib/Doctrine/MongoDB/
Cursor.php (372)
…alled at /vendor/doctrine/mongodb/lib/Doctrine/MongoDB/
Cursor.php (384)
… at /vendor/doctrine/mongodb/lib/Doctrine/MongoDB/Query/
Query.php (277)
…ult called at /module/Blog/src/Blog/Service/
BlogCustomization.php (552)
…ain called at /module/Blog/src/Blog/Controller/
BlogController.php (116)
…r/www/env2/vendor/ZF2/library/Zend/Mvc/Controller/
AbstractActionController.php (83)
in Zend\Mvc\Controller\AbstractActionController::onDispatch called at ? (?)
… called at /vendor/ZF2/library/Zend/EventManager/
EventManager.php (460)
… called at /vendor/ZF2/library/Zend/EventManager/
EventManager.php (204)
…at /vendor/ZF2/library/Zend/Mvc/Controller/
AbstractController.php (117)
…patch called at /vendor/ZF2/library/Zend/Mvc/
DispatchListener.php (114)
in Zend\Mvc\DispatchListener::onDispatch called at ? (?)
… called at /vendor/ZF2/library/Zend/EventManager/
EventManager.php (460)

请帮我找出这个错误的原因.

Please help me to find the cause of this error.

I',从控制器(BlogController.php (116)) 调用一个函数,该函数是写在BlogCustomization.php (552) 上的getUserIdByDomain($domain)

I', calling a function from controller(BlogController.php (116)), the function is getUserIdByDomain($domain) which was written on BlogCustomization.php (552)

参数应始终为子域,例如:prodtest-05.xxx.com.它应该始终是字符串值而不是数组,因为我是从 $_SERVER['HTTP_HOST'] 中获取的.代码应该是这样的

The parameter should always be a sub domain, eg: prodtest-05.xxx.com. It should be always a string value not an array as I'm taking it from $_SERVER['HTTP_HOST']. The code would be like this

在控制器中

$hostname = $_SERVER['HTTP_HOST'];

$result = $model->getUserIdByDomain($hostname);

在模型中

$dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default');
$blog_query = $dm->createQueryBuilder('Blog\Document\Blog')
                        ->field('subdomain')->equals($domain);
$blog_query = $blog_query->getQuery();
$blog = $blog_query->getSingleResult();

错误指向这一行.你能告诉我更多关于这个的信息吗?

The error points to this line. Could you please light me something more on this?

推荐答案

您是否尝试查看 index.php 或 blog/index.php 或调用它们的控制器?您在某处有一个简单的 php 语法错误.可能在像这样的常规字符串中寻找数组和键值的东西

Did u try looking in index.php or blog/index.php or the controllers that call them? You have a simple php syntax error somewhere. Probably look for something that's an array and key value within a regular string like so

echo '$arrayVar['keyname']';

如果你不小心,那些单引号每次都会得到你

those single quotes will get you every time if you're not careful

这篇关于语法错误,意外的“sidebar_bann"(T_ENCAPSED_AND_WHITESPACE),在使用 MongoDB ODM 和 ZF2 时需要“]"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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