[英]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: 无论服务器配置是什么(已通过多次测试),任何运行应用程序的尝试都将以以下两种方式结束:
unexpected T_STRING in .../template/template.html on line 1
, unexpected T_STRING in .../template/template.html on line 1
, Internal Server Error
, Internal Server Error
, 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.