.js.php文件扩展名在文件末尾添加了奇怪的字符

I have an Ubuntu server with a LAMP stack. I have some javascript that has a php include in the middle of it.

For the past year the code has worked fine, but now there is a strange set of characters appearing at the end when viewed in a browser:

It seems to be connected to the .js.php file extension. I can simplify it down to:

In notepad++ it show that there are a couple of extra characters that are actually there:

enter image description here

Its not a standard PHP openend bracket < which might make sense.

Hunting for '.js.php' or the characters in Google is pretty fruitless, so I'm completely stuck.

I had this problem too. The problem seems to be caused by the server gzipping the response incorrectly. (With mod_deflate of course).

Disabling mod_deflate through .htaccess resolved the issue for me - note that you can do something like this to disable per filetype:

SetEnvIfNoCase Request_URI \.*\.js\.php$ no-gzip dont-vary

Strangely, I have two supposedly identical Ubuntu VMs - one where everything runs perfectly, and one where I need to disable mod_deflate. If anyone can figure why this is happening, I'd be interested to know!