tags:

views:

48

answers:

3

While working on an existing Drupal site I've noticed a strange glitch that causes any PHP operator with > in it to act like a ?> tag. This is happening in in Drupal pages that I create that have a 'Input Format' of 'PHP code'.

For example this line of code
foreach($array as $key => $value){
results in a very broken page that prints out
$value){

Does any one know what could be causing this? My Dev environment is XAMPP. Drupal version is 6.15. PHP version is 5.2.9.

UPDATE: Short tags are OFF and when the PHP is rewritten so that it contains no > char it works as expected. I'll have to test more to get additional information.

A: 

are you sure there is <?php infront of the foreach()? some server need the <?php and not just <?

antpaw
+2  A: 

Check if your php.ini has short tags enabled. If not, make sure you always begin every php block with <?php

Lotus Notes
You should do that regardless of your php.ini settings, to ensure against the site being moved to a different server in the future.
Scott Reynen
+1  A: 

If you look in the source, I bet you see the rest of the foreach in there. It's treating > as an HTML end delimiter (and it found a < earlier in the script). Ensure PHP is being parsed. If it isn't being parsed, see if it's because the script requires short tags. If the script uses long tags, make sure PHP itself is up and running properly in the web server.

webbiedave
This seems to be the along the lines of what happened. I think that the pages were crashing such that the remainder of the PHP was being Sent as the remainder of the page. I was not able to cause it to happen again in order to confirm this.
AmaDaden