How to write php code in laravel blade file

in this article, I will share with you how to write PHP code in laravel blade files. there is two ways you should be written PHP code in laravel's blade files. one if laravel provides one his framework method and the second one is the traditional  method of write PHP code in laravel blade file. I will share with you both of example here.

Example : 1

@php
    $Categories = explode(',', $value->category_name);
    $CategoriesSlug = explode(',', $value->category_slug);
@endphp

Example : 2

<?php
    $Categories = explode(',', $value->category_name);
    $CategoriesSlug = explode(',', $value->category_slug);
?>

i hope it will help you.

Tags: