1.demo.php文件内容
<?php
$porm = $_POST['load'] ?? null;
echo $porm;
$file = 'load.php';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>加载</title>
<style>
* {
margin: 0;
padding: 0;
}
div {
width: 1000px;
height: 900px;
margin: 0 auto;
}
div>div {
width: 100%;
height: 33.3%;
}
.btn {
position: fixed;
top: 100px;
left: 50px;
font-size: 18px;
}
h3 {
color: red;
}
</style>
</head>
<body>
<div>
<?
switch (true):
case $porm < 2:
if (file_exists($file) && is_file($file) && $porm) : //条件加载的条件
echo '<h3>条件存在加载</h3>';
include "{$file}";
else :
echo '<h3>条件不存在加载</h3>';
include 'default.php';
endif;
break;
case $porm < 4:
if ($porm == 2) :
echo '<h3>不去重加载</h3>';
include "{$file}";
include "{$file}";
include "{$file}";
else :
echo '<h3>去重加载</h3>';
include_once "{$file}";
include_once "{$file}";
include_once "{$file}";
endif;
break;
case $porm < 6:
if ($porm == 4) :
echo '<h3>强制加载</h3>';
require "{$file}";
require "{$file}";
require "{$file}";
else :
echo '<h3>强制去重加载</h3>';
require_once "{$file}";
require_once "{$file}";
require_once "{$file}";
endif;
break;
case $porm < 8:
if ($porm == 6) :
echo '<h3>include和require加载区别之include加载</h3>';
include "{$file}s";
else :
echo '<h3>include和require加载区别之require加载</h3>';
require "{$files}s";
endif;
break;
endswitch;
?>
</div>
<section class="btn">
<form action="demo.php" method="post">
<select name="load" id="" style='height: 50px; font-size: 16px; background: pink;'>
<option value="0">条件不存在</option>
<option value="1" <? echo $porm == 1 ? 'selected' : null; ?>>条件存在</option>
<option value="2" <? echo $porm == 2 ? 'selected' : null; ?>>不去重加载</option>
<option value="3" <? echo $porm == 3 ? 'selected' : null; ?>>去重加载</option>
<option value="4" <? echo $porm == 4 ? 'selected' : null; ?>>强制加载</option>
<option value="5" <? echo $porm == 5 ? 'selected' : null; ?>>强制去重加载</option>
<option value="6" <? echo $porm == 6 ? 'selected' : null; ?>>include和require加载区别之include加载</option>
<option value="7" <? echo $porm == 7 ? 'selected' : null; ?>>include和require加载区别之require加载</option>
</select>
<input type="submit" value="确定">
</form>
</section>
</body>
</html>
2.load.php文件内容
<?php
$str = <<< DIV
<div class="ifLoad" style="background-color: pink;"></div>
<div class="quzLoad" style="background-color: yellowgreen;"></div>
DIV;
echo $str;
3.default.php文件内容
<?php
$str = <<< 'DIV'
<div class="quzLoad" style="background-color: yellowgreen;"></div>
<div class="ifLoad" style="background-color: pink;"></div>
DIV;
echo $str;