Auto closing PHP tag snippet for Visual Studio Code

HTML Snippet for PHP tag

While working with PHP and HTML codes, we need to write PHP tag (<?php ?>) several times. It wastes our time. We often feel boring too. As Emmet in Visual Studio Code has no shortcut system to append PHP opening and closing tag, we need to create a snippet so that we can add it quickly.

Step 1:

Go to ‘File Preferences User Snippets


Step 2:

Choose ‘html(HTML)‘ here. We are going to create an HTML snippet.


Step 3:

Write the below code in ‘html.json‘ file.



HTML snippet does not support in exact inside of Quotation mark. To enable it, we need to do following steps.

Step 4:

Go to ‘FilePreferencesSettings


Step 5:

Write the below code in ‘settings.json‘ file.



Hurrah! We have done. Now, we are going to check it.

To check,

  • Open a PHP or HTML file in VSCode;
  • Type only ‘php‘, an abbreviation suggestion will appear;
  • Then, press TAB or ENTER button to insert a PHP block;


NOTE: Don’t forget to save changes where needed.


By following this steps, we can create our custom snippet easily.