我目前正在对 vscode 使用 php intelephense(免费)扩展来格式化 php 源代码。
我遇到了以下“奇怪”的行为,有人可以解释为什么以及如何纠正它吗?
最后一个 <?php 标记的缩进不均匀——此外,如果添加了另一段代码,它似乎总是最后一段奇怪的缩进。就像在下面的例子中
示例 1:
function test()
{
$x = 0; ?>
<?php
$y = 0;
if (0 == $x) {
$y = 1; ?>
<?php
$y = 2;
$z = 3;
?>
<?php
}
?>
<?php <--- this tag is not well indented
return $x;
}
示例 2:
function test()
{
$x = 0; ?>
<?php
$y = 0;
if (0 == $x) {
$y = 1; ?>
<?php
$y = 2;
$z = 3;
?>
<?php
}
?>
<?php <--- this tag is well indented
return $x;
}
function test1()
{
$x = 0;
if ($x) {
?>
<?php <--- this tag seems to be not correctly indented
return 0;
}
}