我试过了,但是没有工作:我不知道为什么......
page.php文件
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class takeData extends Controller
{
public function selectdata()
{
$data_users = DB::select('select * from persons where id = :id', ['id' => 1]);
return view('page', ['persons' => $data_users]);
}
}
....
page.blade.php
....
@foreach ($persons as $person)
<p>$person</p>
@endforeach
routes.php文件
Route::get('takeData', 'Page@selectdata');
错误: 哎呀,看起来出事了。
如果我删除&#39; @foreach($ person as $ person)
$ person @ endforeach&#39;在page.blade.php中一切正常,为什么会出错? 非常感谢!!!
答案 0 :(得分:1)