Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP short way to echo string?

In PHP we echo strings this way :

echo 'string';

But i saw PHP frameworks like Laravel and scripts echo strings using Curly Brackets :

{string}

How i can do that without using any PHP framework?

It's not necessary to use Curly Brackets if there is other way to short echo!

I prefer code examples.

like image 638
Amr SubZero Avatar asked Sep 15 '26 15:09

Amr SubZero


1 Answers

PHP has a few methods to print strings, such as (but not limited to) print, and echo or just shorthand <?= "str" ?>.
The bracket print that you ask about from laravel is not per say in php.
That is from a template engine called Blade.

So the {} way of printing stuff is not possible in php.
You will have to stick to the standard ways or use a template engine!

like image 93
Jite Avatar answered Sep 17 '26 03:09

Jite



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!