Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Theme Development WordPress Header and Footer Templates Porting existing headers and footers into WordPress

PHP syntax in Sublime Text

Hey guys, I'm having a hard time getting Sublime to recognize my php files as actual php files in Sublime Text. The bottom corner of the application window indicates that my files are HTML, however, when I try to reset the syntax to PHP I find that it is already checked.

I've tried installing PHP Modern via Package Manager with no luck and my files appear to be saving correctly with the .php file extension. Do I need to start over on my pages for this project with the appropriate syntax or do I have something wrong with my syntaxes with Sublime?

Thanks!

Jenny Veens
Jenny Veens
10,896 Points

Hi Mark,

Have you saved your files with a .php extension?

Jenny, I saved my files with a .php extension when I created them, however, my syntax that is set in Sublime may have been set to HTML when I saved them.

Jenny Veens
Jenny Veens
10,896 Points

So strange! Just for kicks - Have you tried CMD + shift + p and then Set Syntax : PHP?

Is that more or less equivalent of clicking on the listed syntax and selecting something else at the bottom right of the screen? If so, I've tried it. Regardless, I didn't know you could do that with the Command Palette.

I'm thinking I might have to disable one or both of the syntaxes I have for PHP (PHP and PHP 5.....PHP 5 was installed via PHP Modern) and see if that effects anything.

Jenny Veens
Jenny Veens
10,896 Points

It is, but since there is some weirdness I figured it would be worth a try!

Thanks, Jenny! I appreciate the help!

Jenny Veens
Jenny Veens
10,896 Points

Of course! Good luck and let us know if you figure it out :)

The problem was more or less how my php was formatted and, at the time, I didn't have debug set to true in wp_config.php to be able to properly troubleshoot the problem. I had an extra space at the end of one of my page templates after the closing php tag.