当前位置: 动力学知识库 > 问答 > 编程问答 >

How to using echo HTML::script in laravel 5.0 in Controller

问题描述:

I need to use

echo HTML::script('js/ckeditor/ckeditor.js');

网友答案:

HTML and FORM are removed from Laravel 5+ to use them you have to include them in composer.json. And add an Alias and Service Provider in config\app.php You can find them here

And as from laravel 5 {{}} is same as {{e('sting')}} //htmlentities To output html you need to use {!! HTML::() !!} without htmlentities

And if you need to use echo Simply wrap it to <?php ?> tags <?php echo HTML::() ?>

And if you use it Controller you need to use like \Html::() or before Controller class add use HTML;

HTML or Html depends on you Alias array in config\app.php

composer.json

"illuminate/html": "^5.0",

Config/app.php Service Provider

'Illuminate\Html\HtmlServiceProvider',

Config/app.php aliases

'Form'      => 'Illuminate\Html\FormFacade',
'HTML'      => 'Illuminate\Html\HtmlFacade',

Controller

<?php namespace App\Http\Controllers;
use HTML;
class SomeController extends Controller{
    public function foo(){
        echo HTML::();
    }
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: