Php HTML{{}}vs
我有以下问题。我在HTML源代码中编写了以下代码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
<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来使用刀片@露丝·布萨里