Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make visual studio highlight .php files

Hope the title explains it all, but all I'm trying to do is open some .php files in my web-site solution and have Visual studio treat them as if they are html files. I don't need the actual PHJP code highlighted (it's only includes). The HTML syntax should be parse-able, should it not?

like image 418
feihtthief Avatar asked Jul 28 '09 19:07

feihtthief


People also ask

How do I highlight in PHP?

The highlight_string() function outputs a string with the PHP syntax highlighted. The string is highlighted by using HTML tags. The colors used for syntax highlighting can be set in the php. ini file or with the ini_set() function.

Can you edit PHP in Visual Studio?

PHP in Visual Studio Code. Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense (code completion), and snippets out of the box and you can add more functionality through community-created VS Code extensions.


5 Answers

Tools -> Options -> Text Editor -> File Extension

in the Extension box, put .php. For the Editor, you can select HTML Editor. Click Add, then OK

like image 142
Josh E Avatar answered Oct 03 '22 07:10

Josh E


You can also install the PHP Tools for Visual Studio add-in. Tools > Extension and Updates and then search for PHP online. Your first result should be this add-in.

If not, you can get it from here:

http://visualstudiogallery.msdn.microsoft.com/6eb51f05-ef01-4513-ac83-4c5f50c95fb5

like image 37
rxon Avatar answered Oct 03 '22 08:10

rxon


If you want intellisense, debug, and other advanced functionality, you could get the php ide for VS

If all you need is syntax highlighting, check out this link. It's what I'm currently using, but doesn't have all the goodies of vs.php.

like image 35
Rado Avatar answered Oct 03 '22 07:10

Rado


Install Phalanger.

like image 33
Pavel Minaev Avatar answered Oct 03 '22 07:10

Pavel Minaev


If you're using VS2013 or older, I would recommend this extension for PHP Language support : https://visualstudiogallery.msdn.microsoft.com/2a10ba81-26c5-47d9-939b-6bcc7bbec251

For me Josh's solution didn't work and Miguel's solution needs PHP Tools which is free for 30 days but then you need to activate it.

like image 26
WhiteFangs Avatar answered Oct 03 '22 07:10

WhiteFangs