Click to See Complete Forum and Search --> : <?=$foo ?> not being parsed.
the tree
06-11-2006, 07:59 AM
I had a look at a script I wrote ages ago and noticed that part of it was:<?=$message ?>and this was getting completely ignored by the PHP parser, in fact, it was showing up in the source code.
I'm using WAMP and I've updated a few times since looking at this script, so I assume that some setting has fallen out of place but I wouldn't know where to start in fixing this.
Any clues?
NogDog
06-11-2006, 02:38 PM
Your PHP installation would have to have "short tags" enabled for that to work. However, that can be problematic, as "<? xml version='1.0'>" would be interpreted as PHP code; so current versions of PHP do not have short tags turned on by default. So your options are:
1. Search-and-replace "<?=" with "<?php echo" (and "<? " with "<?php "),
2. Enable short_open_tag globally in your php.ini, or
3. Enable short_open_tag for a given directory via .htaccess.
In the long run, I would go with option 1 as it provides the best portability for the code.
felgall
06-11-2006, 05:04 PM
If you decide to go with having short tags enabled then you need to convert
<? xml version='1.0'>
to
echo '<'.'?xml version="1.0"?'.'>';
or similar so that the <? ?> in the XML declaration don't get interpreted as PHP tags.