Ben Fritz wrote:
>
> On Sep 22, 1:14 pm, Mark Manning <[email protected]> wrote:
>   
>> I decided that, since I'm programming in PHP and I wanted to embed PHP
>> code into my HTML code - I wanted to see the PHP code with syntax
>> highlighting.
>>     
>
> I think the usual convention is to include html code in a php file,
> and that the php syntax highlighting includes the html.
>
> Try setting the filetype to php manually or in a modeline.
>
> If you already have a php filetype, then perhaps your html code is
> within a string. :help php.vim details an option to enable
> highlighting html in strings.
> >
>
>
>   
Well, I have done that in the past (ie: PHP file with HTML code embedded 
in it) but I wanted to be able to both edit the HTML as well as edit the 
PHP.  HTML in Dreamweaver, and PHP in vim.  Dreamweaver is ok for 
handling the PHP code but vim is a lot better.  And sure, I've got the 
external editor set to gvim.  Mainly, I wanted to be able to do the 
drag'n drop of HTML features and then go in and clean up the HTML code 
Dreamweaveer generates.  So I did the following in an HTML file:

<?php
    [Do something]
    echo <<<END_OF_HTML
[Put HTML here]
END_OF_HTML;
    [Do some more PHP stuff]
?>

In Dreaemweaver this just shows a blank white page.  Then, when I want 
to edit the HTML code I just:

<?php
    [Do something]
#    echo <<<END_OF_HTML
?>
[Put HTML here]
<?php
#END_OF_HTML;
    [Do some more PHP stuff]
?>

And then Dreamweaver will show the HTML in it with just two PHP tags 
showing.  Further, all of the PHP code embedded into the HTML web page 
shows up.  Now, the PHP code is, in the PHP area, always set into output 
variables (I use $s1...$sN) and so only these variables show up in the 
HTML code.  The nice thing about this approach is that you can see where 
you've put all of the PHP output variables, Dreamweaver doesn't muck 
them around (since $_POST[first_name] is still valid HTML text) and it 
is an easy switch to make the HTML display all of the information.  
Also, it is obvious that the PHP code is or is not being executed.  So I 
get the best of both worlds with vim thrown in as a bonus.  :-)

So to put this in to perspective - the PHP code does generate HTML code 
(or just data) and that is inserted into the HTML code.  I'm just using 
the ".htm" extension so Dreamweaver will display it properly as well and 
allow me to change things in it.  This is why I made the change.  Now 
the PHP.vim file correctly does the coloration even if the source code 
is in an HTML file.  Which it wasn't doing before for me.
Mark

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui