|
Posted by Toby A Inkster on 10/29/48 12:00
Alan Silver wrote:
> If I went through all the .php files in this collection and did a global
> find and replace for "<?" to "<?php" would that do the trick, or is
> there likely to be anything that might get thrown out by this?
Search and replace ought to be fine. Just remember that there are three-
types of shorttag:
<? ... ?>
<% ... %>
<?= ... ?>
The first two should be replaced with:
<?php ... ?>
The last one should be replaced with:
<?php echo ... ?>
The files you need to be careful with are XML files or PHP files that
generate XML output -- this is because '<?' is a commonly used construct
in XML to introduce a "processing instructions", such as an XML version
hint, or link to a CSS stylesheet or XSLT transformation.
Indeed, it's because of this '<?' confusion with XML that shorttag is
disabled by default in more recent versions of PHP. Careful authors can
author XML with PHP with shorttag enabled and not have any problems. But
not everyone is careful. ;-)
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 16 days, 23:29.]
Gnocchi all'Amatriciana al Forno
http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatriciana/
Navigation:
[Reply to this message]
|