FatalErrorException:解析:语法错误,意外的 $end,期待 T_FUNCTION
FatalErrorException: Parse: syntax error, unexpected $end, expecting T_FUNCTION
我开发了一个Symfony2项目
解析错误如下:
FatalErrorException: Parse: syntax error, unexpected $end, expecting
T_FUNCTION in
C:\wamp\www\TPSForm\src\Dwm\CatalogueBundle\Controller\DefaultController.php
line 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());
}
}
您似乎没有关闭 class...它是完整文件吗?在末尾添加结束语 }
当您没有关闭任何左大括号时,通常会出现此错误。
检查左大括号是否正确闭合。
我开发了一个Symfony2项目 解析错误如下:
FatalErrorException: Parse: syntax error, unexpected $end, expecting T_FUNCTION in C:\wamp\www\TPSForm\src\Dwm\CatalogueBundle\Controller\DefaultController.php line 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());
}
}
您似乎没有关闭 class...它是完整文件吗?在末尾添加结束语 }
当您没有关闭任何左大括号时,通常会出现此错误。
检查左大括号是否正确闭合。