Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks

How to use if else condition in Laravel 8 blade file ?

Aman Jain, December 17, 2021January 18, 2022

In this tutorial i will show you to use if else, if and else if in Laravel blade. Laravel use blade engine to render the template and blade have rich features to use conditional statements in file. So here i will show you to use @if, @elseif and @else in blade file.

How to use @if condition in blade ?

In this section we will cover @if and @endif conditional statement with example.

Syntax

@if (condition)
    // code here for the condition 
@endif

Example

$a=5;
@if ($a>5)
    <p>a is greater then 5</p>
@endif

How to use @if and @elseif condition in blade ?

In this section we will cover @if, @elseif and @endif conditional statement with example.

Syntax

@if (condition)
    // code here for the condition 
@elseif(secondconditon)
   // code for second condition 
@endif

Example

$a=5;
@if ($a>5)
    <p>a is greater then 5</p>
@elseif ($a==5)
    <p>a is 5</p>
@endif

How to use @if and @else condition in blade ?

In this section we will cover @if, @else and @endif conditional statement with example.

Syntax

@if (condition)
    // code here for the condition 
@else 
   // code for else condition 
@endif

Example

$a=5;
@if ($a>5)
    <p>a is greater then 5</p>
@else
    <p>a is 5</p>
@endif

How to use @if, @else and @elseif condition in blade ?

In this section we will cover @if, @else, @elseif and @endif conditional statement with example.

Syntax

@if (condition)
    // code here for the condition 
@elseif(secondconditon)
   // code for second condition 
@else
   //code for else
@endif

Example

$a=5;
@if ($a>5)
    <p>a is greater then 5</p>
@elseif ($a==5)
    <p>a is 5</p>
@else
  <p>a is less then 5</p>
@endif

Related

Php Laravel conditionselseelseififlaravel

Post navigation

Previous post
Next post

Related Posts

Php How to ShareSend Message to WhatsApp in Laravel PHP

How to Share/Send Message to WhatsApp in Laravel PHP ?

March 16, 2022March 16, 2022

Sharing or sending message to whatsapp from a website using a link is simple as possible. In this article we will not use any package or third party tool to share the url or message to whatsapp. Whatsapp itself provide to share or send message using the url so in…

Read More
Php Use Soft Delete to Temporary (Trash) Delete the Records in Laravel

Use Soft Delete to Temporary (Trash) Delete the Records in Laravel 9 ?

June 14, 2022June 14, 2022

Soft delete in laravel is use to hide the record from users by keeping the data in the database. In laravel we use Soft Delete to Temporary (Trash) Delete the Records. There is many purpose of soft delete like deleting the user for admin but keep all the information in…

Read More
Php Laravel match password with hash string

How to check password with hashed string in laravel 8 ?

January 26, 2022January 26, 2022

Laravel hashed password with bcrypt algorithm is not decryptable and to match the hashed string with plain string we use Hash::check method. For hashing the password laravel use secure Bcrypt and Argon2 hashing for storing user passwords. So in this tutorial i will show you to check password with hashed…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
  • Understanding High Vulnerabilities: A Deep Dive into the Weekly Summary
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version