karim_fci
karim_fci

Reputation: 1242

PhpStorm producing junk code in PHP starting tag

We are working in a team with a cakephp project where bitbucket is using as version control system. During code deployment once I got an unexpected behavior without any error. After invested long time to investigate the issue, the culprit find out. In the file starting code, there is strange notation included like following:

error picture

What is the solution to avoid this issue? Help is very much needed because in very large project it is difficult to track in which file this problem exist. Thanks in advance.

Upvotes: 1

Views: 70

Answers (1)

Cameron Hurd
Cameron Hurd

Reputation: 5041

This is a Byte Order Mark, shown above as CP1252 characters! 

I don't believe that phpstorm would've put that there, but it definitely preserves it if it's already present.

You should install PHP Code Sniffer and run phpcs /path/to/project/dir --sniffs=Generic.Files.ByteOrderMark to find if there are any other BOMs in your files and remove as needed. Then ask your team whose IDE may be adding them.

Upvotes: 2

Related Questions