Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
特殊字符不';t在php symfony twig程序中工作_Php_Special Characters_Twig - Fatal编程技术网

特殊字符不';t在php symfony twig程序中工作

特殊字符不';t在php symfony twig程序中工作,php,special-characters,twig,Php,Special Characters,Twig,我的symfony程序中的特殊字符有问题, 我通常使用UTF-8保存页面,而不使用BOM(我使用记事本++) 例如,此页面正确显示: je suis lé <h1>Ajouter un acteur</h1> {% if message %} <p>{{ message }}</p> {% endif %} <form action="" method="post" {{ form_enctype(form) }}> {

我的symfony程序中的特殊字符有问题, 我通常使用UTF-8保存页面,而不使用BOM(我使用记事本++) 例如,此页面正确显示:

    je suis lé
<h1>Ajouter un acteur</h1>
{% if message %}
<p>{{ message }}</p>
{% endif %}
<form action="" method="post" {{ form_enctype(form) }}>
    {{ form_widget(form) }}
    <input type="submit" />
</form>
<p><a href="{{ path('myapp_acteur_lister') }}">Retour à la liste des acteurs</a></p>
以下是该页面的截图:


如何实现这一点?

确保控制器php文件也使用UTF-8保存。

是的,你是对的,我忘了使用UTF-8保存控制器文件,而不使用BOM
public function editerAction($id = null)
{
     $message='';
     $em = $this->container->get('doctrine')->getEntityManager();
     if (isset($id)) 
     {
      // modification d'un acteur existant : on recherche ses données
      $acteur = $em->find('MyAppFilmothequeBundle:Acteur', $id);
      if (!$acteur)
      {
       $message='Aucun acteur trouvé';
      }
     }
     else 
     {
      // ajout d'un nouvel acteur
      $acteur = new Acteur();
     }
     $form = $this->container->get('form.factory')->create(new ActeurForm(), $acteur);
     $request = $this->container->get('request');
     if ($request->getMethod() == 'POST') 
     {
            $form->bindRequest($request);
     if ($form->isValid()) 
     {
      $em->persist($acteur);
      $em->flush();
      if (isset($id)) 
      {
       $message='Acteur modifié avec succès !';
      }
      else 
      {
       $message='Acteur ajouté avec succès !';
      }
     }
     }
     return $this->container->get('templating')->renderResponse(
    'MyAppFilmothequeBundle:Acteur:editer.html.twig',
     array(
     'form' => $form->createView(),
     'message' => $message,
     ));
}