我想使用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")
我想使用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)
有没有办法做这样的事情?