vitto
vitto

Reputation: 19476

Is '<?=' the same as 'echo'?

I've found some page where people print strings on the web page with this:

<?= 'hello world'; ?>

Is this a faster way to print strings in one row of code or does it work different?

Upvotes: 5

Views: 202

Answers (3)

genesis
genesis

Reputation: 50976

Yes. This would work as echo, but it IS NOT RECOMMENDED and many servers have got this availability disabled. It's called "short tag"

Upvotes: 4

Yeroon
Yeroon

Reputation: 3243

It's not exactly the same as just echo, it's a shortcut syntax.

<?= 'hello world'; ?>

would be the same as:

<?php echo 'hello world'; ?>

The latter is recommended because short_open_tags might be disabled on your server.

Upvotes: 2

T.J. Crowder
T.J. Crowder

Reputation: 1074335

According to the documentation, the <?= ... ?> form is a shortcut for echo, so they should be the same from a performance perspective.

Upvotes: 2

Related Questions