Wednesday, September 28, 2022
HomePHPHow To Show HTML Tags In Blade With Laravel 8

How To Show HTML Tags In Blade With Laravel 8


On this tutorial, you’ll discover ways to show HTML in Blade with Laravel 8. I’m assuming, you could have fundamental information PHP and laravel. We’ll create a pattern blade template and show HTML.

What’s Blade Template Engine

Blade Templates could also be used on your frontend utilizing Laravel, a incredible PHP framework.

The blade is a strong templating engine included with Laravel that permits customers to make use of normal PHP code of their views.

Blade view recordsdata that use the .blade.php file extension and are saved within the assets/views listing.

Stipulations

A Laravel software is up and working, if not please create a brand new laravel software and run the server.

Show HTML In Laravel Blade Views

You could create a blade template file hey.blade.php within the assets/views folder.

The blade template is utilizing syntax {{}} to entry a variable that are outlined within the controller methodology.

Sponsored Hyperlinks

You should utilize syntax {{ $some_variable }} to echo out the content material of a particular variable in Blade.

Let’s outline a hey variable in a controller methodology:

$hello_msg = "<h2>Hiya, Good morning</h2>";

$hello_msg assortment which has H1 HTML components within the string, when you had been to make use of the next:

<div>{{ $hello_msg }}</div>

Output:

<h2>Hiya, Good morning</h2>

When you don’t need your HTML tags to be escaped then you must use {!! !!} similar to this:

Output:

Hiya, Good morning

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments