How to Comment Code in Laravel Blade File?

By Hardik Savani November 5, 2023 Category : Laravel

Hey,

In this profound tutorial, we will learn how to comment in laravel blade file. step by step explain laravel blade comment. In this article, we will implement a laravel add comment laravel blade file. We will use how to add comment code in laravel.

To add a comment in a blade file in Laravel, you can use the {{-- --}} syntax. Anything written within these comment tags will not be rendered in the final HTML output. Here's an example:

You can include comments to explain your code or to temporarily disable certain parts of the code without actually removing them.

Let's see the example code:

Laravel Comment Code in Blade File

Blade File Code:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title></title>

</head>

<body>

{{-- <h1>How to comment code in laravel?</h1> --}}

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</body>

</html>

Laravel Comment Code in Controller File

You can use following Normal PHP comments as like the below:

/* multiple line comments */

// single line comments

# simple comments :)

Controller File Code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Illuminate\Support\Str;

class UserController extends Controller

{

/**

* Display a listing of the resource.

*

* @return \Illuminate\Http\Response

*/

public function index(Request $request)

{

$result = Str::containsInSensitive('Hi, Hardik', 'Hardik');

$result2 = Str::containsInSensitive('Hi, Hardik', 'hardik');

dd($result, $result2);

}

}

I hope it can help you...

Tags :
Shares