Home > Backend Development > PHP Tutorial > laravel (1) routing, parameter passing, blade laravel how to read laravel development tutorial laravel framework

laravel (1) routing, parameter passing, blade laravel how to read laravel development tutorial laravel framework

WBOY
Release: 2016-07-29 08:50:45
Original
1779 people have browsed it

  1. Every time you access laravel, you will be directed to the routes.php file
  2. Usually a route will be handed over to a controller method for processing

controller

1. Create controller
`php artisan make:controller controllername`
Note: `php artisan make:controller controllername –plain`does not carry custom methods
2.Use controller
Routes: Route::get('/','SitesController@index');
SC:

<code><span>public</span><span><span>function</span><span>index</span><span>()</span> {</span><span>return</span><span>"sjming"</span>;
    }</code>
Copy after login

3. Parameter passing
(1)Single value:
SC:

<code><span>public</span><span><span>function</span><span>index</span><span>()</span> {</span><span>$name</span> = <span>'sjming'</span>;
        <span>return</span> view(<span>'welcome'</span>)->with(<span>'name'</span>,<span>$name</span>);
    }</code>
Copy after login

(2) array

<code><span>return</span> view<span><span>(<span>'welcome'</span>)</span>-></span><span>with</span>([
    <span>'name'</span><span>=></span>$name,
    <span>'first'</span><span>=></span><span>'su'</span>
]);</code>
Copy after login

(3) as a parameter of view

<code><span>$data</span>=[];
    <span>$data</span>[<span>'first'</span>]=<span>'123'</span>;
    <span>$data</span>[<span>'second'</span>]=<span>'456'</span>;
    <span>return</span> view(<span>'sites.about'</span>,<span>$data</span>);</code>
Copy after login

(4) php’s compact

<code><span>$fir</span>=<span>'123'</span>;
   <span>$sec</span>=<span>'456'</span>;
   <span>return</span> view(<span>'sites.about'</span>,compact(<span>'fir'</span>,<span>'sec'</span>));</code>
Copy after login

4. Parameter usage
Escape method: {{}} //The html in it is not interpreted
Unescaping method: {!! !!} //The html explanation

blade template

  1. @yield('xxx'),@extends('xxx')
  2. @section('xxx'),@ stop
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced laravel (1) routing, parameter passing, and blade, including the content of laravel and blade. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template