Jump to content

Problem with <? vs. <?php


webkidd

Recommended Posts

Firstly, always back up your php.ini file before you make any changes

Try searching for short_open_tag and see what value it is set to (0 or 1).  From the information in the link I gave you, I would assume that 0 is off and 1 is on?
Link to comment
Share on other sites

Easier and future proof:

open the file in notepad:
ctrl+h

replace <?
with <?php

ctrl+h

replace: phpphp
with: php

If it's loads of files.. won't be hard to write a small replace script:

[code]<?php

function replaceTags($dir, $ext)
{
    if (!$dir = realpath($dir)) return false;

    $hand = opendir($dir);

    while(($item = readdir($hand)) !== false)
    {
        $path = realpath($dir . DIRECTORY_SEPARATOR . $item);
        if (!in_array($item, array('.', '..')))
        {
            if (!is_readable($path)) continue;

            if (is_dir($path))
            {
                replaceTags($path, $ext);
            }
            elseif (strtolower(substr($path, -strlen($ext))) == strtolower($ext))
            {
                $content = file_get_contents($content);
                $content = preg_replace(
                          array('/<?\s{1}/', '/<?=/'),
                          array('<?php ', '<?php echo '),
                          $content
                );
                file_put_contents($path, $content);
            }
        }
    }
    closedir($hand);
}

replaceTags('/var/www/doc_root', '.php');

?>[/code]

untested
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.