PHP not recognized between DOM elements

I feel like the answer to this must be obvious, but given the frequency of the words used to describe the issue, I'm having a hard time searching for a resolution to this.

Basically, when I have code such as this:

<div >
if ($a = 'b'):

All of the PHP that is within DOM nodes isn't recognized as PHP. PHPStorm thinks that it's HTML, despite the fact that it's enclosed in PHP tags.

PHP within the HTML tag itself, such as this:

<div ></div>

works just fine. Only PHP between the opening and closing HTML tags causes a problem.

Any ideas?


Hi there,

Please attach:
1) example file
2) scheenshot of how it looks on your computer

But before that -- "File | Invalidate Caches" in case if you have not done it yet.

BTW -- what PhpStorm version do you use exactly (Help | About) ?


Unfortunately, it doesn't apepar that invalidating the cache had much effect. When PHPStorm loaded, everything was displaying correctly. Within a couple of seconds, it went back to what you see in this image:

None of the PHP is apparently being recognized. It seems to be viewed as HTML.

The attached file is what is shown in the image.


Purelly based on screenshot -- you have Custom Language injected (somehow) into one of the tags (the green backgound .. so most likely DIV).

Alt+Enter while caret standing there and choose "Uninject"
"Settings | Language Injections" and disable/delete offending one (will be of "global" or "project" type -- not "bundled")


Look at that! You saved the day!

Now, maybe I could bother you for another quick question, since you clearly know more about the software than I do. This one is about formatting. All of my formatting is perfect except for one thing, and I can't figure out how to change it:

When I write JavaScript, and then automatically refactor it, I want to get this:

    alert('Nice script!');

But what I get is this:

                         alert('Nice script!');

I mean, I understand the point is to show that the code is part of the function, but it makes for some odd looking code.

How would I go about fixing this?

PS. PHPStorm is absolutely fantastic, and worth every penny!


Settings | Code Style | JavaScript | Wrapping and Braces -- all relative options will be there

You will need play and adjust Function call arguments (I believe)


You are good!

Thank you so much for all of your help!


Please sign in to leave a comment.