ItSolutionStuff.com

How to Comment Code in Laravel Blade File?

By Hardik Savani • November 5, 2023
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: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Count the Number of Words in String in Laravel?

Read Now →

How to Check String is URL or Not in Laravel?

Read Now →

Laravel Check If String Starts with Specific Value Example

Read Now →

How to Convert String to CamelCase in Laravel?

Read Now →

How to Get Length of String in Laravel?

Read Now →

Laravel Convert String to Uppercase Example

Read Now →

Laravel Convert String to Lowercase Example

Read Now →

Laravel Import Large CSV File Using Queue Example

Read Now →

How to Replace String in Laravel?

Read Now →

How to Install and Setup Supervisor in Ubuntu for Laravel?

Read Now →

Laravel String Contains Case Insensitive Example

Read Now →

Laravel Stripe Checkout Payment Integration Example

Read Now →

How to Convert String to Array Conversion in Laravel?

Read Now →