Home >Backend Development >PHP Tutorial >laravel (1) routing, parameter passing, blade laravel how to read laravel development tutorial laravel framework
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>
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>
(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>
(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>
(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>
4. Parameter usage
Escape method: {{}} //The html in it is not interpreted
Unescaping method: {!! !!} //The html explanation
blade template
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.