我正在使用具有普通視圖和控制器的Laravel 5.4。Laravel頁面錯誤 - 在每頁的頂部打印1
在我web.php我有以下途徑:
Route::get('/quiz', '[email protected]');
Route::post('quiz/submit', array('uses' => '[email protected]'));
一切工作正常,我開始寫檢查()函數
public function check(Request $request)
{
$answers = array_flatten($request->except('_token'));
$quiz = config('enums.quiz');
$correct = [];
$result = [];
foreach ($quiz as $key => $value) {
foreach ($value as $key => $val) {
if ($val == 1) {
array_push($correct, $key);
}
}
}
foreach ($answers as $key => $value) {
if ($correct[$key] == $value) {
$result[$value] = 1;
}else {
$result[$value] = 0;
}
}
$request->session()->flash('results', $result);
redirect('/quiz');
}
和quiz.blade.php
@extends('layouts.app')
@section('content')
<div class="panel panel-default">
<div class="panel-heading">
Quiz
</div>
<div class="panel-body">
{!! Form::open(array('id'=> 'updateForm', 'style'=>'margin-bottom:10px;' ,"class"=>"form-horizontal" , "ng-app"=>"userform", 'url' => array('quiz/submit'))) !!}
<ol type="1">
@foreach ($questions as $question => $answers)
{{-- loop throgh each question --}}
<li class="question">
<h4>
<strong>
{{ $question }}
</strong>
</h4>
<ol type="a">
@foreach ($answers as $answer => $isCorrect)
{{-- looping answers of the question --}}
<li class="answer ">
<input name="answer_{{ $loop->parent->index }}" required="" type="radio" value="{{ $answer }}">
{{ $answer }}
</input>
</li>
@endforeach
</ol>
</li>
@endforeach
</ol>
<button class="btn btn-ok btn-default text-uppercase pull-right">Clear Answers</button>
<span style="margin: 5px;" class="pull-right"> </span>
{!! Form::submit('Submit Quiz', array('id'=>'btn_submit', 'class' => 'btn btn-ok btn-primary text-uppercase pull-right ')) !!}
{!! Form::close() !!}
</div>
</div>
@endsection
然後突然它開始打印在每頁的頂部。即使我試圖清除編譯和清除會話,但仍然會造成問題。
php artisan clear-compiled
1The compiled services file has been removed.
相同1被印刷在每一頁的頂部,因此,停止登錄或任何其它頁面請求的請求。
在此先感謝
如果它正在打印'1',它不是'dd()'語句,它是'echo'語句。可能在刀片佈局中有一個'{{$ var}}'回聲(就像@Benjamin King所說的)',或者它是代碼中的'echo $ var'。如果它在任何HTML之前打印(檢查源代碼),那很可能是這種情況。 – Ohgodwhy
我看到它無處不在 它也出現在所有的PHP工匠命令 它似乎像laravel緩存或什麼的問題,但我無法看到任何解決方案 –
Laravel緩存不是問題,你有什麼地方的東西。 – Ohgodwhy