在PHP中创建刀片式视图模板
扩展布局并将视图文件划分为多个部分,其中渲染时,“x”部分位于布局的“x”部分内。就像在blade中使用在PHP中创建刀片式视图模板,php,laravel,laravel-blade,Php,Laravel,Laravel Blade,扩展布局并将视图文件划分为多个部分,其中渲染时,“x”部分位于布局的“x”部分内。就像在blade中使用@extend()和@section()[]一样。我只想在我自己的PHP上实现它,而不使用任何库或框架。blade就是这样做的: 布局文件[app.blade.php] <html> <head> <title>App Name - @yield('title')</title> </head>
@extend()
和@section()
[]一样。我只想在我自己的PHP上实现它,而不使用任何库或框架。blade就是这样做的:
布局文件[app.blade.php]
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
@extends('layouts.app')
@section('title', 'Page Title')
@section('sidebar')
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<p>This is my body content.</p>
@endsection
应用程序名称-@yield('title'))
@节(“侧栏”)
这是主侧边栏。
@展示
@产量(‘含量’)
查看文件[my page.blade.php]
<html>
<head>
<title>App Name - @yield('title')</title>
</head>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
@extends('layouts.app')
@section('title', 'Page Title')
@section('sidebar')
<p>This is appended to the master sidebar.</p>
@endsection
@section('content')
<p>This is my body content.</p>
@endsection
@extends('layouts.app'))
@节(“标题”、“页面标题”)
@节(“侧栏”)
这将附加到主侧边栏
@端部
@节(“内容”)
这是我的身体内容
@端部
no?在视图代码中不使用include或require。查看该刀片文件的已处理.php文件,您将看到它是如何完成的。这是否回答了您的问题?不,我想重新创建它,所以我需要有关如何创建它的代码的帮助。否?在视图代码中不使用include或require。查看该刀片文件的已处理.php文件,您将看到它是如何完成的。这是否回答了您的问题?不,我想重新创建它,所以我需要有关如何创建它的代码的帮助。