我想包含到我的master.blade.php中的一個top.blade.php文件,但我最終出現了這個錯誤:Laravel @include進主佈局結果如下:PHP致命錯誤:允許內存大小爲134217728字節耗盡
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in /Websites/Hermann_Sofa/html/vendor/laravel/framework/src/Illuminate/View/Factory.php on line 534
也許我做錯了什麼? 謝謝!
route.php:
Route::get('/', function() {
return view('home');
});
home.blade.php:
<!-- Stored in resources/views/ -->
@extends('layouts.master')
@section('content')
<p>This is my body content.</p>
@stop
top.blade.php:
<!-- Stored in resources/views/ -->
@extends('layouts.master')
@section('top')
<div class="right col-md-4 pull-right">
<span class="phone"><span class="glyphicon glyphicon-earphone"></span> 0743 443.566</span>
<span class="text-right" data-toggle="modal" data-target="#loginModal"><span class="fa fa-shopping-cart"></span>COSUL</span>
</div>
<div class="left col-md-8 hidden-xs">
<span class="label label-warning">PROMOTII</span><span class="promo_1"> Promotii speciale de weekend!</span>
</div>
@endsection
master.blade.php:
<!-- Stored in resources/views/layouts/master.blade.php -->
<html>
<head>
<title>Sofa</title>
</head>
<body>
<div class="top">
<div class="container">
@include('top')
</div>
</div>
<div class="foo">
</div>
</body>
</html>
看來你有內存泄漏的地方,它是你整個代碼?您可以嘗試將'@ stop'更改爲'@ endsection',因爲您在頂部視圖和本地視圖中使用了不同的結束標記。你也可以通過在代碼中執行'ini_set('memory_limit','256M');'來暫時設置更高的內存限制。 –
這是造成主和頂之間的無限循環 – feareoc