【问题标题】:FatalErrorException: Parse: syntax error, unexpected $end, expecting T_FUNCTIONFatalErrorException:解析:语法错误,意外 $end,期待 T_FUNCTION
【发布时间】:2015-05-19 10:30:59
【问题描述】:

我开发了一个 Symfony2 项目 解析错误如下:

FatalErrorException: Parse: 语法错误,意外 $end,期待 T_FUNCTION 在 C:\wamp\www\TPSForm\src\Dwm\CatalogueBundle\Controller\DefaultController.php 第 57 行

谁能指出我正确的方向来解决这个问题。

class DefaultController extends Controller
{
/**
 * @Route("/hello/{name}")
 * @Template()
 */
 public function indexAction($name)
 {
    return array('name' => $name);
 }
 /**
 * @Route("/addCategorie/{nomCat}")
 * @Template()
 */
 public function addCatAction($nomCat)
 {
    $em=$this->getDoctrine()->getManager();
    $cat=new Categorie();
    $cat->setNomCategorie($nomCat);
    $em->persist($cat);
    $em->flush();
    return array('cat' => $cat);
 }
 /**
 * @Route("/newProduit")
 * @Template()
 */
 public function newProduitAction(Request $request)
 {
    $p=new Produit();
    $form=$this->createFormBuilder($p)
        ->add("nomProduit","text")
        ->add("prix","text")
        ->add("categorie","entity",array(
            "class"=>"Dwm\CatalogueBundle\Entity\Categorie",
            "property"=>"nomCategorie"
            ))
        ->add("Add","submit")
        ->getForm();
    $form->handleRequest($request);
    if($form->isValid()){
        $em=$this->getDoctrine()->getManager();
        $em->persist($p);
        $em->flush();
    return array('f' => $form->createView());
    }
   }

【问题讨论】:

  • 我认为您的课程缺少右括号
  • 请包括任何尝试解决您自己尝试过的问题,这可以帮助人们更容易地识别错误。欢迎来到 SO :)

标签: php symfony fatal-error


【解决方案1】:

看起来你没有关闭你的课程......它是完整的文件吗?在末尾添加结束 }

【讨论】:

  • 是的,是的,我好像忘记关闭它们了
【解决方案2】:

当您没有关闭任何左大括号时,通常会出现此错误。

检查所有左大括号是否正确闭合。

【讨论】:

    猜你喜欢
    • 2011-07-23
    • 2011-04-13
    • 2017-11-04
    • 2015-05-26
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 2010-11-20
    • 2021-11-05
    相关资源
    最近更新 更多