Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.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
Php HTML{{}}vs_Php_Laravel - Fatal编程技术网

Php HTML{{}}vs

Php HTML{{}}vs,php,laravel,Php,Laravel,我有以下问题。我在HTML源代码中编写了以下代码 <form action = "/user/register" method = "post"> <input type = "hidden" name = "_token" value = "<?=csrf_token()?>"> <table> <tr> <td>Nam

我有以下问题。我在HTML源代码中编写了以下代码

      <form action = "/user/register" method = "post">
         <input type = "hidden" name = "_token" value = "<?=csrf_token()?>">

         <table>
            <tr>
               <td>Name</td>
               <td><input type = "text" name = "name" /></td>
            </tr>

            <tr>
               <td colspan = "2" align = "center">
                  <input type = "submit" value = "Register" />
               </td>
            </tr>
         </table>

      </form>
当我更改为{{csrf_token}}时,我收到一个错误:tokenmischException。 为什么?在Laravel中和{{}之间有什么区别?

{}通过调用htmlspecialchars函数自动转义字符串,或者{!!!!}不转义。您可以阅读刀片模板的文档。但是{{csrf_token}}必须工作。尝试使用{csrf_field}}自动添加输入:

<form action = "/user/register" method = "post">
  {{ csrf_field() }}

  <table>
     <tr>
        <td>Name</td>
        <td><input type = "text" name = "name" /></td>
     </tr>

     <tr>
        <td colspan = "2" align = "center">
           <input type = "submit" value = "Register" />
        </td>
     </tr>
  </table>

</form>

我认为问题在于,在示例中,我没有使用刀片模板系统。您可以简单地在文件名中添加.blade.php而不是.php来使用刀片@露丝·布萨里