Have php with echoing html tags. notepad++ 6.4.5 is highlighting ok the tags inside php and outisde php.

notepad++ 6.5 is highlighting ok the tags only outisde php and NO HIGHLIGHT inside php code.

How to enable highlighting of tags inside php code?

notepad++ 6.4.5: enter image description here enter image description here

notepad++ 6.5:

enter image description here enter image description here

  • I just saw this line in the change log, apparently previously this was considered a bug: 9. Fix a tag matching bug by disabling tag matching inside PHP code blocks. – Ryan Oct 10 '13 at 20:28
  • yes, thanks, I raised a bug ticket - sourceforge.net/p/notepad-plus/bugs/4510 . Waiting for project owner to try to solve that. – ihtus Oct 10 '13 at 21:43
  • @ihtus That would be a feature request, not a bug. – Alex W Oct 25 '13 at 19:39
  • Alex: that "feature" was present in previous versions – ihtus Oct 25 '13 at 20:04

I was expecting a solution from the developers of notepad++, by bringing back the feature of highlighting html code inside php code. But that is not happening... So got a temporary workaround:

1) Open php file in notepad++

2) Set HTML languahe: go to Language => H => HTML

3) Now html tags are highlighted in php code.

If you will close and open once again the php file, you will have to execute 1-3 again.

To make this automatically done:

EDIT langs.xml

1) Replace

<Language name="html" ext="html htm shtml shtm xhtml hta"


<Language name="html" ext="html htm shtml shtm xhtml hta php"

That will make php files to be parsed as html language

2) Replace

<Language name="php" ext="php php3 phtml"


<Language name="php" ext="php1 php3 phtml"

That will disable php files to be parsed as php language. If not doing step 2 => step 1 has no effect.

EDIT functionList.xml:

Function list will be empty after those changes. Here is the fix: Need to edit functionList.xml

1) Replace:

<association langID="6" id="java"/>
<association langID="9" id="xml_node"/>


<association langID="6" id="java"/>
<association langID="8" id="html_function"/>
<association langID="9" id="xml_node"/>

2) just after last is closed, add this (it's a copy of php_function renamed to html_function):

        <parser id="html_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
                mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[\w]+([\s]*|[\s]*(extends|implements)[\s]+[\w\\]+[\s]*)?\{"
                openSymbole = "\{"
                closeSymbole = "\}"
                    <nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
                    <nameExpr expr="[\s]+[\w]+\Z"/>
                    <nameExpr expr="[\w]+\Z"/>
                        <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+[\s]*\([^\{]*"/>
                        <!-- comment below node if want display method with parmas -->
                        <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>

                    <nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
                    <nameExpr expr="(?!(if|while|for))[\w_]+"/>
                    <nameExpr expr="[\w_]+(?=[\s]*::)"/>

EDIT \plugins\APIs\html.xml and \plugins\APIs\php.xml (this is needed for notepad++ version 6.9.1 and above)

1) Copy content in php.xml between <AutoComplete>...</AutoComplete> and paste it to html.xml, before </AutoComplete>


You should be creating your PHP documents as templates of HTML documents, as seen below. Notepad++ is just supporting good coding practices by treating your echo strings as PHP strings and not highlighting them. If you want to break into HTML, then just put a ?> to end the PHP syntax highlighting and it will highlight it as HTML. Then use <?php to start PHP code again, as necessary. You don't need echo to output HTML, just end the <?php ... ?> block and type your HTML like you normally would.

<!doctype html>
   <div><?php echo "content"; ?></div>
  • php is set as language for both cases. it's about html tags highlighting inside php. – ihtus Oct 9 '13 at 13:39
  • I think that "PHP documents as templates of HTML documents" is very uncomfortable, so I will not use this. – ihtus Oct 24 '13 at 19:36
  • @ihtus That is the whole point of PHP is to generate templates of HTML and other static files by processing the dynamic information on the server side. – Alex W Oct 24 '13 at 19:39
  • Alex: the template you suggest is good when you have a lot of static html + some dynamic information generated by php. In most cases I work at - static html is a small part of a lot php code written for dynamic interactions. So again, the HTML template you suggest does not work for me. – ihtus Oct 25 '13 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.