PHP configuration problem - <? instead of <?php

Soldato
Joined
21 Oct 2002
Posts
3,008
Location
At home of course :p
Hi all

I'm trying to move a website someone else has programmed to a new server and the new site is displaying the php code rather than executing it.

Now I looked at the index.php of the site and there are lines of code such as the following;

<? include("connection.php");?>

If I change this to the following, it works fine;

<?php include("connection.php");?>

Therefore the issue seems to be that the programmer used <? instead of <?php

Since there are over 100 webpages, is there an easier way of simply changing all the code. I.e. is there a setting I can change to make php execute <? instead of just <?php

The server is running IIS and has php 5 installed on it.

Any help greatly appreciated.
 
<? is depreciated though, so preferably change all the tags to <?php. It may be more effort but probably for the best.
 
Thanks everyone - that sorted it out

@FabienO - understand completely where you're comming from. I've already told them the site needs reprogramming and to obtain quotes but unfortunately that decision isn't mine to make.
 
It confuses the parser and throws an error if you use short tags.

The <? and <?xml tags conflict.

But if the <? tag is not in the output, why would any parser get confused? The parser would parse the output of the PHP script and not the source code surely?
 
OK I can see the problem happening there but the larger problem in that case would be the fact you're spaghetti coding! I'm hoping it was just an example!
 
Consider this..

Code:
<?xml version="1.0"?>
<Book>
<bookname><? echo "Gone with the wind"; ?></bookname>
</Book>

Would throw an error.

If that's the wrong way to do it would this be the right way to do it?

PHP:
<?
$bookname = 'Gone with the wind';
echo '<?xml version="1.0"?>
<Book>
<bookname>',$bookname,'</bookname>
</Book>';
?>

I'm only asking as I want to improve my coding practices. :)
 
Back
Top Bottom