小编Sea*_*oth的帖子

如何使用PHP显示一个或多个HTML页面?

我想使用PHP和if语句,我想这样做

if ($variable){
display html page1
}
else {
display html page2
}
Run Code Online (Sandbox Code Playgroud)

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

--EDIT--我对其中一个做这个没有问题,但另一个文件,这样做太麻烦了.

--EDIT--到目前为止这是编码:

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

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

html php if-statement

2
推荐指数
1
解决办法
2万
查看次数

有没有办法用PHP引用外部文档中的变量?

我想使用PHP做一些小事,但我需要知道如何从外部文件(例如external.php)获取变量并将其用于PHP文档中的函数(internal.php).我想的可能是这样的:

external.php的代码

$variable = "true";
Run Code Online (Sandbox Code Playgroud)

internal.php的代码

if ($GETFROM{'/external.php'}['variable']) 
echo "It worked";
Run Code Online (Sandbox Code Playgroud)

有没有办法做这样的事情?

php variables document reference external

0
推荐指数
1
解决办法
241
查看次数

标签 统计

php ×2

document ×1

external ×1

html ×1

if-statement ×1

reference ×1

variables ×1