Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can print Laravel variable with echo [duplicate]

Tags:

php

echo

laravel

<?php echo Form::open(['method' => 'POST', 'url' => ['/cart/add/'. "{{$product->product_id }}"]] )?>
<?php echo Form::button('Agregar al Carro', ['class' => 'btn-u btn-u-sea-shop btn-u-lg', 'type' => 'submit']) ?>
<?php echo Form::close()  ?>

I need to print the variable $product in a template.

like image 376
Santiago García Cabral Avatar asked Jun 08 '17 05:06

Santiago García Cabral


1 Answers

You can echo it with php like:

<?php echo $product->product_id ?>

and in blade syntax like:

{{$product->product_id}}

and in your case it should be like:

'url' => [ '/cart/add/'. $product->product_id ]

only concatenation is required here

like image 81
Mayank Pandeyz Avatar answered Oct 21 '22 13:10

Mayank Pandeyz