简体   繁体   中英

Sublime Text 2 php endforeach, endif, and endwhile get confused widh html closing tag

So the problem is basically the autoindent. I use this in the user configuration for auto indent on f12

{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }

And in a somefile.php with html code and php code

<div>
    <?php if(something):?>
         hello world
    <?php endif;?>
</div>

F12 results in

<div>
    <?php if(something):?>
        hello world
<?php endif;?> //sublime is thinking the endif is a closing html tag.
</div>

Is there a way to fix this?

try to change it to:

<div>
<?php 
    if(something){
      echo "hello world" // I assume you want to print this line to the screen
    }
 ?>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM