Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.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 Laravel在视图中显示错误_Php_Error Handling_Laravel_Laravel 4 - Fatal编程技术网

Php Laravel在视图中显示错误

Php Laravel在视图中显示错误,php,error-handling,laravel,laravel-4,Php,Error Handling,Laravel,Laravel 4,如果验证失败,我将执行以下操作: return Redirect::back()->with('validation', $validation->errors->all()); 我还使用: $restful = true; 因此,当我在get_edit()-我得到一个错误,生成视图时没有$validation变量,当我在post_edit()-这一切都没问题,因为它返回一个带有错误的重定向 我的看法是: <? foreach($validation as $e):

如果验证失败,我将执行以下操作:

return Redirect::back()->with('validation', $validation->errors->all());
我还使用:

$restful = true;
因此,当我在
get_edit()
-我得到一个错误,生成视图时没有$validation变量,当我在
post_edit()
-这一切都没问题,因为它返回一个带有错误的重定向

我的看法是:

<? foreach($validation as $e): ?>

<div><?= $e; ?></div>

<? endforeach; ?>
因此,变量存在但为空,但现在出现了一个新问题,每次执行此筛选器后,它都会覆盖生成我的
post_edit()
$validation
,而且我在视图中看到一个变量
$errors
,但始终为空,我不知道如何使用它,您能帮助我吗

所以很快我的问题是:

public function get_edit($id)
{
   //generate my view with all nessesary data, but i can't generate here an error variable
   // or its better to put it in one place to globally share it in the views, otherwise i am     //getting an error
}

public function post_edit($id)
{

  //validating $_POST data, if there is an error redirect it back to the get_edit() WITH a        //variable containing errors

}
你看过文件了吗

您可以使用
returnredirect::back()->withErrors($validation)
在视图中,始终可以使用重定向('register')->withErrors($validator)
$errors
,而无需将它们绑定到视图

public function get_edit($id)
{
   //generate my view with all nessesary data, but i can't generate here an error variable
   // or its better to put it in one place to globally share it in the views, otherwise i am     //getting an error
}

public function post_edit($id)
{

  //validating $_POST data, if there is an error redirect it back to the get_edit() WITH a        //variable containing errors

}