简体   繁体   English

PHP App在localhost上完美运行,在任何Web服务器上完全失败,并出现一些奇怪的错误

[英]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. 我设计了一个非常简单的PHP应用程序。 Works perfectly on localhost (XAMPP / Windows 7) and fails completely on any web server, to which I upload it. 在localhost(XAMPP / Windows 7)上可以完美运行,并且在我将其上传到的任何Web服务器上完全无法运行。 Error displayed during failure say nothing to me. 失败期间显示的错误对我无能为力。

Whatever server configuration is (tested on many) any attempt of run application ends with either: 无论服务器配置是什么(已通过多次测试),任何运行应用程序的尝试都将以以下两种方式结束:

  • PHP error: unexpected T_STRING in .../template/template.html on line 1 , PHP错误: unexpected T_STRING in .../template/template.html on line 1
  • HTTP error 500: Internal Server Error , HTTP错误500: Internal Server Error
  • empty page (assuming, error reporting disabled). 空白页(假设,错误报告已禁用)。

File template/template.html is just an ordinary XHTML file, with correct header, body and structure, containing some simple PHP statements. 文件template/template.html只是一个普通的XHTML文件,具有正确的标题,正文和结构,包含一些简单的PHP语句。 I load and parse it with require in following function: 我在以下函数中使用require加载并解析它:

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. 这是我自己的非常简单的函数版本,用于Yii(可能还有许多其他框架)来呈现视图,子视图或模板。 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. 如果有人想检查一下,那么 这里是(应该是)实时版本,而 这里包含SVN导出版本的压缩归档文件就出自我在本地主机上的本地工作副本之外,在这里工作就像一个梦。 (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. 我已经开发了许多PHP应用程序,无论是使用纯PHP还是使用Yii框架,这都是我第一次遇到这种情况,因此我感到非常震惊和迷茫。 Up until now, every application that was running without errors on my localhost (XAMPP) also run without any problems on any webhost. 到现在为止,在我的本地主机(XAMPP)上运行且没有错误的每个应用程序在任何Web主机上都可以正常运行。

Any idea or help is higly appreciated. 任何想法或帮助都将受到赞赏。

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 ?> ). 检查您的Apache服务器是否设置为允许PHP短标记( <? ?> ),因为template.html的第一行具有短标记(文档中的其他标记均为长<?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); ?> 另外,您在回显命令的末尾错过了同一文件中第27行的分号,应为<?php echo($alert); ?> <?php echo($alert); ?> . <?php echo($alert); ?> Don't know if it helps anything, but just in case. 不知道它是否有帮助,但以防万一。

Regards, Hiawatha 问候,Hiawatha

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的Web应用在服务器上看起来与众不同,并且可以在localhost上完美运行 - my web app looks different on server and works perfectly on localhost PHP问题(在localhost上有效,但在Web服务器上错误) - Problem with PHP (works on localhost, but errors on web server) 站点在localhost上完美运行,但在服务器上运行不正常 - Site works perfectly on localhost, but not on server PHP - file_get_contents() 在 localhost 但在实时服务器上完美运行 - PHP - file_get_contents() works perfectly on localhost but on live server PHP代码可在服务器上运行,但在本地主机中引发错误 - PHP code works on server but throws errors in localhost PHP curl可在localhost上运行,但不能在Web服务器上运行吗? - PHP curl works on localhost but not on the web server? PHP INSERT 查询不适用于 web 服务器,但适用于 localhost。 没有返回错误 - PHP INSERT query doesn't work on web server but works on localhost. No errors returned 填充php数组变量不适用于godaddy服务器(php版本5.3.24)在localhost中完美运行 - populating php array variable is not working in godaddy server(php version 5.3.24) works perfectly in localhost URL完全适用于localhost,不适用于Web服务器 - URL perfectly working on localhost, not working on web server google CAPTCHA在HTTPS上失败,可以在本地主机上完美测试 - google CAPTCHA fails on HTTPS works perfectly testing on localhost
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM