如何使用PHP显示一个html页面或另一个html页面? [英] How do I use PHP to display one html page or another?

查看:874
本文介绍了如何使用PHP显示一个html页面或另一个html页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用PHP和if语句,并且想做

I wanted to use PHP and the if statement, and I wanted to do

if ($variable){
display html page1
}
else {
display html page2
}

我该怎么做?请注意,我不想将用户重定向到其他页面.

How do I do this? An please note, that I do not want to redirect the user to a different page.

-编辑- 我对其中一个进行此操作没有问题,但是对另一个文件而言,这样做很麻烦.

--EDIT-- I would have no problem doing that with one of them, but the other file, it would be too much of a hassle to do that.

-编辑- 这是到目前为止的编码:

--EDIT-- Here is the coding so far:

<?PHP
include 'uc.php';
if ($UCdisplay) {
    include("under_construction.php");
}
else {
    include("index.html");
}
?>

我的问题是,如果必须为每个php页面创建一个html页面,那将非常复杂且令人困惑,因此我需要某种方式来显示完整的html页面,而不是使用include("index.html" )

My problem is that it would be really complicated and confusing if I were to have to create an html page for every php page, so I need some way to show the full html page instead of using include("index.html")

推荐答案

if ($variable){
  include("file1.html");
}
else {
  include("file2.html");
}

这篇关于如何使用PHP显示一个html页面或另一个html页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆