[Wylug-help] vim line in PHP/HTML file

Martyn Ranyard ranyardm at gmail.com
Tue Apr 16 15:41:20 UTC 2013


Hi Smylers,

The original reason was that "<?" means "Web server, pass this to your
scripting host", "<?php" means "Web server pass this to your php
interpreter".  This has kind of fallen by the wayside, however - short tags
are not necessarily supported (they can and often are turned off in
php.ini) and also as php is ostensibly a templating language it can be used
for templating xml.  When in an xml file being parsed by a php interpreter,
"<?xml" becomes interesting with short tags enabled.

There is another tag "<?=" which is slightly different as well - it is the
same as typing "<?php echo" and as of 5.4, this is made distinct from short
tags, but in 5.3 it comes under short tags, so disabling it in php.ini will
disable both.

Cheers,
--
Martyn


On 16 April 2013 16:18, Smylers <Smylers at stripey.com> wrote:

> Martyn Ranyard writes:
>
> > short codes are BAD!
>
> Hi Martyn. Out of interest -- why?
>
> > the correct way to tell a php interpreter that you want code to be
> > interpreted is "<?php".  Perhaps vim is discouraging this old bad
> > practice, try the following :
> >
> > <?php // vim: ft=php nowrap ai et ic
>
> Nope, Vim doesn't try to interpret the PHP in any way.
>
> Vim only cares about "vim:" at the top (or bottom) of a file and what
> follows it; anything before that gets ignored by Vim.
>
> > Also, worth noting that current best practice is to omit the final
> > "?>" at the end of the file, as that leads to random blank lines,
> > which end up in your output and causes output to happen often before
> > headers are sent by webservers.
>
> Makes sense. Thanks.
>
> Smylers
> --
> Stop drug companies hiding negative research results.
> Sign the AllTrials petition to get all clinical research results published.
> Read more: http://www.alltrials.net/blog/the-alltrials-campaign/
>
> _______________________________________________
> Wylug-help mailing list
> Wylug-help at wylug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/wylug-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/wylug-help/attachments/20130416/9b371d58/attachment.html>


More information about the Wylug-help mailing list