trejder
trejder

Reputation: 17513

PHP App works perfectly on localhost and fails completely on any web server with some strange errors

I have designed a very simple PHP app. Works perfectly on localhost (XAMPP / Windows 7) and fails completely on any web server, to which I upload it. Error displayed during failure say nothing to me.

Whatever server configuration is (tested on many) any attempt of run application ends with either:

File template/template.html is just an ordinary XHTML file, with correct header, body and structure, containing some simple PHP statements. I load and parse it with require in following function:

public static function renderPartial($view, $data = array())
{
    if(is_file($view))
    {
        if(is_array($data)) extract($data, EXTR_PREFIX_SAME, 'data');

        ob_start(); 
        ob_implicit_flush(false); 

        require($view);

        return ob_get_clean();
    }
    else die('File <strong>"'.$view.'"</strong> does not exist!');
}

It is my own, very simple version of function used in Yii (and probably many other frameworks) to render view, subview or template. I use it in many places in my app and it works like a charm on localhost.

If someone would like to check then here is (should be) live version, while here zipped archive containing SVN exported version right out of my local working copy on localhost, which works here like a dream. (problem solved -- examples removed)

I have developed many PHP apps, both in pure PHP or with using Yii framework, and this is first time I have such situation, so I'm quite shocked and lost. Up until now, every application that was running without errors on my localhost (XAMPP) also run without any problems on any webhost.

Any idea or help is higly appreciated.

Upvotes: 0

Views: 464

Answers (1)

sh0ne
sh0ne

Reputation: 390

Check if your Apache server is set to allow short-tags ( <? ?> ) for PHP, because the first line of template.html has short tags (the other tags in the document are all long <?php ?> ). Also, you missed a semi-colon on the line 27 in the same file, at the end of the echo command, should be <?php echo($alert); ?>. Don't know if it helps anything, but just in case.

Regards, Hiawatha

Upvotes: 1

Related Questions