php php文件显示空白页

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20182799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:57:56  来源:igfitidea点击:

Php files show blank page

phpapache

提问by user753152

i have php 5.3.1 installed on apache2 in ubuntu 12.04 server . my site was working fine untill last week when i found some of the files were missing and website was not showing.I uploaded site again on server and now when i browse any php pages it shows a blank page and also when i try to see the source code in browser for the blank page it dosnt show any source code.the html files are all showing up.

我在 ubuntu 12.04 服务器的 apache2 上安装了 php 5.3.1。我的网站运行良好,直到上周我发现某些文件丢失并且网站没有显示浏览器中空白页面的源代码,它不显示任何源代码。html 文件都显示出来了。

i dont think it is the server or appache2 probelm as i have other site with php on the same server working fine. i checked with php files they are alrite.checked with the htacces.txt and that is same as the other working site on the same server. can anyone here help what the problem could be.

我不认为这是服务器或 appache2 问题,因为我在同一台服务器上有其他带有 php 的站点工作正常。我检查了 php 文件,它们是 alrite.checked 和 htacces.txt,这与同一服务器上的其他工作站点相同。任何人都可以帮助这里的问题可能是什么。

thanks

谢谢

Rida

丽达

回答by Denys Vitali

Check error logs in /var/log/apache2/error.log

检查错误日志 /var/log/apache2/error.log

回答by Ale

I got the same problem while installing a third party LAMP application and the cause was missing php5-mysql package.

我在安装第三方 LAMP 应用程序时遇到了同样的问题,原因是缺少 php5-mysql 包。

Hope this helps others.

希望这对其他人有帮助。

回答by Gaurav Kispotta

Sometime this white screen may occur because of the php pagethat is included by include()and include_once()functions, which may have some error or any syntax errorthat are notreported by the php server.

有时这种白色的屏幕可能是因为发生PHP页面由包括include()include_once()功能,其中可能有一些错误或者语法错误被PHP服务器报告。

This happens because the included php pageare executed first before the actual php page and if any errorthat is present in the included fileoccurs that suppresses the error catching then further php codes are not executedand a blank page is displayed.

这是因为包括PHP页面首先执行的实际PHP页面之前,如果任何错误是存在于包含的文件时,抑制了错误捕获,然后进一步的PHP代码不会被执行并且会显示空白页

  • First try to find that which dependent filehas the problem by //toggling each include()or includ_once()one at a time.
  • After the culprit dependent file is found try to check it for the errors.
  • 首先尝试通过一次切换每个或一个来找出哪个依赖文件有问题。//include()includ_once()
  • 找到罪魁祸首依赖文件后,尝试检查它是否有错误。

回答by Arthur

In my case this happened when I un-installed Zend using its uninstall.sh, I then needed to edit the Apache config /etc/apache2/sites-enabled/000-default.conf to remove any references to Zend Server. I did restart Apache, but restarting the whole machine helped to revive PHP bindings.

在我的情况下,当我使用其uninstall.sh 卸载 Zend 时发生这种情况,然后我需要编辑 Apache 配置 /etc/apache2/sites-enabled/000-default.conf 以删除对 Zend Server 的任何引用。我确实重新启动了 Apache,但重新启动整个机器有助于恢复 PHP 绑定。

回答by Humphrey

In my case I find out that the include_once() function which I put on the top of the page was the problem . I red the answer by Gaurav Kispotta , that is where I got the tip . so if you have the same problem first comment that out , maybe even the entire code depending on that include .

就我而言,我发现我放在页面顶部的 include_once() 函数是问题所在。我红了 Gaurav Kispotta 的答案,那是我得到小费的地方。因此,如果您遇到相同的问题,请先将其注释掉,甚至可能是整个代码都取决于包含的内容。

回答by AntoineWtrd

You should never ever use require_once or include_once.

你永远不应该使用 require_once 或 include_once。

It will burst your server memory.

它会破坏您的服务器内存。

Just go with include or require.

只需使用 include 或 require 即可。

回答by Rafsanmoney

php is a server side language so viewing source from browser will not yield any result if the whole codes are surrounded by php tags. Download the files from the server using an ftp client and try to open in an editor to see if there are still codes in it.

php 是一种服务器端语言,因此如果整个代码都被 php 标签包围,那么从浏览器查看源代码将不会产生任何结果。使用 ftp 客户端从服务器下载文件并尝试在编辑器中打开以查看其中是否仍有代码。