Php

How To Display HTML Tags In Blade With Laravel 8

In this tutorial, you will learn how to display HTML in Blade with Laravel 8. I am assuming, you have basic knowledge PHP and laravel. We’ll create a sample blade template and display HTML.

What’s Blade Template Engine

Blade Templates may be used for your frontend using Laravel, a fantastic PHP framework.

The blade is a robust templating engine included with Laravel that allows users to use standard PHP code in their views.

Blade view files that use the .blade.php file extension and are stored in the resources/views directory.

Prerequisites

A Laravel application is up and running, if not please create a new laravel application and run the server.

Display HTML In Laravel Blade Views

You need to create a blade template file hello.blade.php in the resources/views folder.

The blade template is using syntax {{}} to access a variable which are defined in the controller method.

Related Post

You can use syntax {{ $some_variable }} to echo out the content of a specific variable in Blade.

Let’s define a hello variable in a controller method:

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

$hello_msg collection which has H1 HTML elements in the string, if you were to use the following:

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

Output:

<h2>Hello, Good morning</h2>

If you don’t want your HTML tags to be escaped then you should use {!! !!} just like this:

Output:

Hello, Good morning

View Comments

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More

4 months ago

What is the Purpose of php_eol in PHP?

in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More

10 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

10 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

10 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

11 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

11 months ago

Categories