views:

94

answers:

5

i have one complete website

which was written in php4, now my hosting server is PHP Version 5.3.2, windows 2008 server

and my site is not working, what i found is old site use following syntax

<?

but if i change it into

<?php

page start working. is there any way to solve this issue...

  1. PHP Version 5.3.2 work with

    <?
    
  2. any script which change all

    <? to <?php 
    

    in all pages.

Thanks

+2  A: 

Short tags are a discouraged feature of PHP. You should convert all <? to <?php, because as of PHP 6.0, they will be deprecated. (This is partially to better support XML documents, which have a tag that starts with <?)

BTW, you can turn them on in your configuration.

Chacha102
+10  A: 

This is not down to the PHP version, but depends on the short_open_tag php.ini setting.

You can change the ini setting to "1", but the use of short open tags is generally discouraged these days.

Pekka
It's mostly discouraged for code that would be under your control (forever). The server needs to have the short open tag enabled, otherwise it won't work. Starting with PHP6 the tag will be _disabled_ by default. So if you build a project for a company and you have no idea what the settings on their server will be, it's best to use the default `<?php` and not take a risk. But when your building this for yourself or for your own company and you know that you'll be controlling the severs on which it runs, there no reason not to use it. It does has it advantages, depending on your coding style.
Alec
@Alec good points. Whether or not to use short open tags is subject to fiercest discussion :) There are those who condemn it altogether, and those who like the `<?=$varname;?>` notation. I personally still have a lot of code with short open tags, but strive to move to `<?php` as soon as possible.
Pekka
@Alec, you are right, but even if you know that you'll have control on the server configuration, you don't know how long... Maybe you'll get hired somewhere else, and people after you could not know about your use of short_open_tags
Boris Guéry
A: 

Hello air,

There is a directive in your php.ini file called "short_open_tag". This is what allows you to use the shorthand or not. They should not be used anymore though, so its better if you update all tags to the new format.

Metropolis

Metropolis
A: 

Hi, the following code snippet helped me convert all short tags to proper PHP tags, hope it helps you too:

http://mirmodynamics.com/post/2009/01/29/Replacing-short-tags-with-proper-PHP-tags

Geoffrey Bachelet
A: 

Does anyone know why it was disabled at all? There is usually some vague mention of incompatibility to XML editors or something. But I've never seen a factual/common real world scenario where <?= caused problems.

Well yes, xmllint doesn't like it. But who sends PHP scripts through an XML parser anyway?

mario