Sublime Forum

PHP syntax highlighting broken with CSS

#1

Hi - I’m a new Mac user and am trying to find my Notepad++ alternative. Sublime looks and works just as well as Notepad++ except for one very strange behaviour. When I add embedded CSS into one of my PHP files and not complete the CSS statements, I result with something like that found in the following image.

If the image doesn’t work, please check out tinypic.com/r/jqght3/6

The colour syntax fixes itself if you add the closing bracket next to “body {”. Unfortunately, I need to use PHP within some of those CSS rules (eg output custom colours/widths…). To replicate, here’s the same code:

<?php

	// this is some PHP comment
	if ( true )
		phpinfo();
	else
		echo 'awesome'

?>
<style type="text/css">
body {

<?php
	
class test
{
	function __construct()
	{
		if ( true )
			phpinfo();
	}
}
?>

} // end body
</style>
<?php
	if ( true )
		phpinfo();
?>

I am using Sublime Text 2.0.1 on Mountain Lion. Any thoughts/suggestions are warmly appreciated. Thanks!

Btw, been trying some of the other main editors and none of the others had the same syntax highlighting issue.

0 Likes

#2

The comment

// end body

is incorrect at that location. But I agree that php code within css is not recognised.


0 Likes