Welcome Guest, Not a member yet? Register   Sign In
Poll: Should Short Echo tags be used
You do not have permission to vote in this poll.
My opinion is no.
20.00%
1 20.00%
My opinion is yes.
80.00%
4 80.00%
There is objective (non-opinion) reason not to.
0%
0 0%
There is objective (non-opinion) reason to use them.
0%
0 0%
Total 5 vote(s) 100%
* You voted for this item. [Show Results]

CI4 Best Practice for Echo Shortcut Tag
#1

(This post was last modified: 09-23-2021, 12:53 AM by objecttothis. Edit Reason: Formatting )

Preface: According to PHP, as of version 5.4 `<?=` is always available regardless of the value of `short_open_tags`, so comments regarding compatibility are irrelevant.

Does CodeIgniter have a best practice for the use of the Echo Shortcut Tag (e.g., `<?= $foo ?>`) vs echo notation (e.g., `<?php echo $foo; ?>`)?

- PSR-1 just states that tags should be limited to `<?php` or `<?=`.
- PHP states that using a semi-colon in the short echo tag is redundant.
- PSR-2 and PSR-12 don't mention the tag.
- Ryan Seachrest's style guide says that the echo shortcut tag should be used when possible.
- Wordpress style guide says no.
- CakePHP style guide says yes.
- I can't find anything from CodeIgniter saying that one should be used over the other.
Reply
#2

Don't worry. CodeIgniter loves your choice.

But the User Guide uses <?= $foo ?> style.

See
https://codeigniter4.github.io/CodeIgnit...ting-loops
Reply
#3

Our coding standard uses the short echo style whenever possible.
https://github.com/CodeIgniter/coding-st...#L114-L118
Reply




Theme © iAndrew 2016 - Forum software by © MyBB