'Why is VS Code removing closing tag ?> on save. anyone knows?

when i save my php file then VS Code removes ?> tag from ending. and its causing problems in execution. I dont know why is this happening. If anyone knows please help. Thank u.

Update: I was using Es-lint and Prettier extensions at the same time. I removed them and now its fine.



Solution 1:[1]

I find two ways to solve this problem.

  1. Go to VSCode settings and in the search bar type "format", then uncheck Editor: Format on save. Formatting the code will no longer work, but VSCode will also not delete the PHP closing tag.

  2. Install the php cs fixer extension and I hope it will solve the issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vukasin