我想要做的是將一個站點的HTML存儲在一個PHP變量中,以便在特定條件下可以回顯該變量。我的PHP代碼:如何在PHP變量中存儲HTML
<?php
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$URL = "http://www.example.com/";
$URL2 = "http://www.example2.com/";
$website1 = ?
$website2 = ?
if($url == $URL) {
echo $website1;
} else if($url == $URL2) {
echo $website2;
}
?>
我想這HTML(如下圖)存儲在$website1
也將有HTML保存在$website2
<html>
<head>
<link rel='stylesheet' type='text/css' media='all' href='css/style.css'>
<link rel='stylesheet' type='text/css' media='all' href='css/jquery-ui-1.10.4.custom.css'>
<title>Website #One</title>
<script type='text/javascript' src='js/jquery-1.9.1.js'></script>
<script type='text/javascript' src='js/jquery-ui-1.10.4.custom.js'></script>
<script type='text/javascript' src='js/script.js'></script>
</head>
<body>
<div id='header'></div>
<div id='menu'>
<button id='navbtn' class='active btn'>Home</button><button id='navbtn2' class='btn'>Pictures</button><button id='navbtn3' class='btn'>Videos</button><button id='navbtn4' class='btn'>Games</button><button id='navbtn4' class='btn'>About</button><button id='navbtn5' class='btn'>Contact</button>
</div>
<div id='content'></div>
</body>
</html>
我怎麼能做到這一點?
您可以使用指向html文件的file_get_contents。 – 2014-10-29 11:31:28