ShortEchoTagCanBeUsed
info off by default quick-fixGroup: Code style · PhpStorm name: ShortEchoTagCanBeUsedInspection
In templates, a PHP block that only outputs something — <?php echo $x ?> — reads better as the short echo tag <?= $x ?>.
Example
php
<ul>
<li><?php echo $item->name; ?></li>
<li><?php echo strtoupper($code) ?></li>
<li><?PHP echo $first, ' ', $last; ?></li>
<li><?php print $total; ?></li>
<li><?php print($note) ?></li>
<li><?= $already ?></li>
<li><?php echo $a; echo $b; ?></li>
<li><?php /* hint */ echo $c ?></li>
</ul>php
<ul>
<li><?= $item->name ?></li>
<li><?= strtoupper($code) ?></li>
<li><?= $first, ' ', $last ?></li>
<li><?= $total ?></li>
<li><?= ($note) ?></li>
<li><?= $already ?></li>
<li><?php echo $a; echo $b; ?></li>
<li><?php /* hint */ echo $c ?></li>
</ul>Reported:
- line 2: Use the short echo tag '<?= … ?>' here.
- line 3: Use the short echo tag '<?= … ?>' here.
- line 4: Use the short echo tag '<?= … ?>' here.
- line 5: Use the short echo tag '<?= … ?>' here.
- line 6: Use the short echo tag '<?= … ?>' here.
Configure
In custos.json:
json
{
"rules": {
"ShortEchoTagCanBeUsed": {
"enabled": true
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore ShortEchoTagCanBeUsed
/**
* @noinspection ShortEchoTagCanBeUsedInspection
*/