Skip to content

Define Variable In Blade Templates Laravel?

Blade did not provided a way to define variables.But you can extend blade by using extend method as shown below

Blade::extend(function($value) {
    return preg_replace('/\@var(.+)/', '', $value);
});

How to use

@var $variableName = "variableValue"

That’s it.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments