尊龙凯时人生就是博

̽ÌÖLaravel5.0°æ±¾ÖеÄÄ£°åÓ÷¨

laravelÊÇÒ»¿îÊ¢ÐеÄphp¿ò¼Ü£¬ËüÌṩÁËÐí¶àÇ¿Ê¢µÄ¹¦Ð§ºÍ¹¤¾ß£¬ÒÔ×ÊÖú¿ìËÙ¿ª·¢¸ßÖÊÁ¿µÄwebÓ¦ÓóÌÐò¡£ÆäÖÐÒ»¸öÖ÷ÒªµÄ¹¦Ð§¾ÍÊÇÄ£°åÒýÇ棬ËüʹµÃ¿ª·¢ÕßÄܹ»¸üÇáËɵع¹½¨ÑŹۡ¢¿É¸´ÓõÄÒ³Ãæ¡£±¾ÎĽ«Ì½ÌÖlaravel5.0°æ±¾ÖеÄÄ£°åÓ÷¨£¬²¢ÌṩһЩÊÊÓõļ¼Çɺͽ¨Òé¡£

Laravel5.0Ä£°åÒýÇæµÄ»ù´¡

Laravel5.0ʹÓÃBladeÄ£°åÒýÇ棬ËüÌṩÁËһϵÁеÄÄ£°å×é¼þºÍÓï·¨£¬ÒÔ×ÊÖú¿ìËÙ¹¹½¨ÑŹ۵ÄÒ³Ãæ¡£BladeÄ£°åÒýÇæ¾ßÓÐÒÔÏÂÌص㣺

Óï·¨¾«Á·£ºBladeÌṩÁ˾«Á·µÄÓï·¨£¬Ê¹µÃÄ£°å´úÂëÔ½·¢Ò׶ÁÒ×ά»¤¡£

¿ÉÀ©Õ¹ÐÔ£º¿ª·¢Õß¿ÉÒÔͨ¹ý×Ô½ç˵ָÁîµÈ·½·¨À©Õ¹BladeÄ£°åÒýÇæµÄ¹¦Ð§¡£

Ö§³ÖÄ£°å¼ÌÐø£ºBladeÔÊÐí¿ª·¢Õßͨ¹ýÄ£°å¼ÌÐøµÄ·½·¨À´ÖØÓÃÒ³Ãæ½á¹¹ºÍÑùʽ¡£

Laravel5.0Ä£°åÒýÇæµÄÓï·¨

BladeÄ£°åµÄÓï·¨ÒÔ'{{}}’×÷Ϊ±ê¼Ç£¬ÌåÏÖÊä³öÄ£°å±äÁ¿¡£ÀýÈ磺

<h1>{{ $title }}</h1>

µÇ¼ºó¸´ÖÆ

ÔÚÄ£°åÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃ’if-else’Óï¾ä¡¢’foreach’Ñ­»·ºÍ’include’°üÀ¨ÆäËûÄ£°åµÈͨÀýÓï·¨¡£ÀýÈ磺

@if(count($items) &gt; 0)
    

µÇ¼ºó¸´ÖÆ

    @foreach($items as $item)         

{{ $item }}

    @endforeach     

@else     

No items

@endif @include(‘partials.footer’)

ÔÚÉÏÃæʾÀýÖУ¬’if-else’Óï¾ä¼ì²éitems±äÁ¿ÊÇ·ñΪ¿Õ£¬ÈôÊDz»Îª¿ÕÔòʹÓÃ’foreach’Ñ­»·¾ÙÐбéÀú£¬È»ºóͨ¹ý'{{}}’½«±äÁ¿Êä³öµ½HTMLÖС£×îºó£¬Í¨¹ý’@include’Ö¸ÁîÒýÈëÃûΪ’partials.footer’µÄÄ£°å¡£

Laravel5.0Ä£°åÒýÇæµÄ¿ØÖƽṹ

BladeÄ£°åÒýÇæÌṩÁËһЩ¿ØÖƽṹ£¬ÓÃÓÚ¸üÖØ´óµÄÂß¼­´¦Àí¡£ÒÔÏÂÊÇһЩÊÊÓõĿØÖƽṹ£º

@foreachÑ­»·£º

@foreach($items as $item)
    

µÇ¼ºó¸´ÖÆ

{{ $item }}

@endforeach

@forÑ­»·£º

@for($i = 0; $i {{ $items[$i] }}
@endfor

µÇ¼ºó¸´ÖÆ

@ifÌõ¼þ£º

@if(count($items))
    {{ $items[0] }}
@endif

µÇ¼ºó¸´ÖÆ

@unlessÌõ¼þ£º

@unless(count($items))
    <p>No items found!</p>
@endunless

µÇ¼ºó¸´ÖÆ

@includeÄ£°å°üÀ¨£º

@include('partials.header')

µÇ¼ºó¸´ÖÆ

@extendsÄ£°å¼ÌÐø£º

@extends('layouts.master')

@section('content')
    <p>This is the body.</p>
@endsection

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖУ¬’@extends’Ö¸¶¨Ä£°å¼ÌÐøµÄ½á¹¹£¬’@section’½ç˵ÁËÄ£°åÖеÄÄÚÈÝ¿é¡£×ÓÄ£°åÖÐͨ¹ýʹÓÃ’@yield’Ö¸ÁîÀ´äÖȾ¸¸Ä£°åÖеÄÄÚÈÝ¿é¡£

Laravel5.0Ä£°åµÄ½á¹¹¼ÌÐø

BladeÄ£°åÒýÇæÔÊÐí¿ª·¢ÕßʹÓýṹ¼ÌÐøµÄ·½·¨¶ÔÒ³Ãæ¾ÙÐнṹ¡£Í¨¹ý½ç˵Ö÷½á¹¹£¨³ÆΪMaster Layout£©ºÍ×ӽṹ£¨³ÆΪChild Layout£©£¬ÎÒÃÇ¿ÉÒÔÔÚ×ӽṹÖÐÀ©Õ¹Ö÷½á¹¹£¬²¢½ç˵¸÷¸ö²¿·ÖµÄÄÚÈÝ¿é¡£ÒÔÏÂʾÀýÑÝʾÁËÔõÑù½¨Éè½á¹¹¼ÌÐø£º

Ö÷½á¹¹

<!-- resources/views/layouts/master.blade.php -->
nbsp;html&gt;

    
        <title>@yield('title')</title>
        <link>
    
    
        @yield('content')
    

µÇ¼ºó¸´ÖÆ

×ӽṹ

<!-- resources/views/layouts/child.blade.php -->
@extends('layouts.master')

@section('title', 'My Home Page')

@section('content')
    <p>This will be displayed in the body.</p>
@endsection

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæʾÀýÖУ¬×ӽṹ¼ÌÐøÁËÖ÷½á¹¹£¬²¢½ç˵ÁËÒ»¸öÃûΪ’content’µÄ²¿·Ö¡£Í¨¹ýÔÚÖ÷½á¹¹ÖÐʹÓÃ’@yield’Ö¸ÁÎÒÃÇ¿ÉÒÔÖ¸¶¨¸Ã²¿·ÖµÄλÖúÍÄÚÈÝ¡£ÔÚ×ӽṹÖУ¬½ÓÄÉ’@section’Ö¸ÁîÀ´Ìî³ä¸Ã²¿·ÖµÄÄÚÈÝ¡£

Laravel5.0Ä£°åµÄ¹ýʧ´¦Àí

ÔÚ¿ª·¢WebÓ¦ÓóÌÐòʱ£¬¹ýʧ´¦ÀíºÜÊÇÖ÷Òª¡£Í¨¹ýLaravel5.0µÄÄ£°åÒýÇ棬ÎÒÃÇ¿ÉÒÔÇáËɵش¦ÀíÒ³ÃæÉϵĹýʧ¡£ÒÔÏÂÊÇһЩÊÊÓõĹýʧ´¦Àí¼¼ÇÉ£º

¼ì²é±äÁ¿ÊÇ·ñ±£´æ£º

{{ $foo or 'default' }}

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖУ¬$foo±äÁ¿Î´½ç˵ʱ½«»áÏÔʾĬÈÏÖµ’default’¡£

¼ì²é±í´ïʽÊÇ·ñΪÕ棺

{{ $foo ? 'yes' : 'no' }}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖУ¬ÈôÊÇ$foo±äÁ¿ÎªÕ棬ÔòÏÔʾ’yes’£¬²»È»ÏÔʾ’no’¡£

ÈôÊÇijЩ±äÁ¿Î´½ç˵£¬Ê¹ÓÃĬÈÏÖµ£º

{{ $foo or 'default' }}

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄʾÀýÖУ¬ÈôÊÇ$foo±äÁ¿Î´½ç˵ʱ½«Ê¹ÓÃĬÈÏÖµ’default’¡£

¼ì²é±íµ¥¹ýʧ£º

@if(count($errors))
    <div>
        <ul>
        @foreach($errors-&gt;all() as $error)
            <li>{{ $error }}</li>
        @endforeach
        </ul>
    </div>
@endif

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæʾÀýÖУ¬Ê¹ÓÃ@ifÓï¾ä¼ì²é$errors±äÁ¿ÊÇ·ñΪ¿Õ¡£ÈôÊDZ£´æ¹ýʧ£¬Ôòͨ¹ý’@foreach’Ö¸ÁîÊäÍÉ»¯ÎóÐÂÎÅ¡£

¼ì²éÄ¿½ñURL²¢Ìí¼ÓCSSÀࣺ


µÇ¼ºó¸´ÖÆ

    Home

ÔÚÉÏÃæʾÀýÖУ¬Ê¹ÓÃ’Request::is()’ÒªÁì¼ì²éÄ¿½ñURLÊÇ·ñΪ’home’£¬ÈôÊÇÊÇ£¬ÔòÌí¼ÓCSSÀà’active’¡£

×ܽá

ÔÚLaravel5.0ÖУ¬Ä£°åÒýÇæÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ¹¦Ð§£¬ËüΪ¿ª·¢´ó¹æÄ£WebÓ¦ÓóÌÐòÌṩÁËÀû±ãµÄ¹¤¾ß¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËBladeÄ£°åÒýÇæµÄ»ù´¡Óï·¨ºÍ³£Óü¼ÇÉ¡£ÈôÊÇÄú¸Õ¸Õ×îÏÈѧϰLaravel5.0£¬ÎÒÃÇÇ¿ÁÒ½¨ÒéÄúÉîÈëÑо¿ºÍʵ¼ùBladeÄ£°åÒýÇæ¡£Ëü½«Ê¹ÄúÔÚ¿ª·¢WebÓ¦ÓóÌÐòʱ¸üÒ×Óᢸü¿ìËٺ͸üÎÞа¡£

ÒÔÉϾÍÊÇ̽ÌÖLaravel5.0°æ±¾ÖеÄÄ£°åÓ÷¨µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ