【发布时间】:2019-06-13 01:11:36
【问题描述】:
我想知道是否有任何方法可以在外部管理 a href。这样我就不必处理更新每个 html 文件中的链接。
我不确定 PHP 是否可以处理该问题或使用 cpython。如果有人能指出我正确的方向。这将非常有帮助。谢谢。
<nav>
<ul>
<li>
<a href="index.html">Homepage</a>
<ul>
<li><a href="sitemap.html">Sitemap</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li><a href="certification.html">Certifications</a></li>
</ul>
</li>
<li>
<a href="web_development/webdevelopment.html">Web Development</a>
<ul>
<li><a href="web_development/html.html">HTML</a></li>
<li><a href="web_development/css.html">CSS</a></li>
<li><a href="web_development/javascript.html">JavaScript</a></li>
<li><a href="web_development/jquery.html">jQuery</a></li>
<li><a href="web_development/ascii.html">ASCII Table</a></li>
</ul>
</li>
<li>
<a href="programming_languages/programming.html">Programming Languages</a>
<ul>
<li><a href="programming_languages/c.html">C</a></li>
<li><a href="programming_languages/c++.html">C++</a></li>
<li><a href="programming_languages/java.html">Java</a></li>
</ul>
</li>
<li>
<a href="scripting_languages/scripting.html">Scripting Languages</a>
<ul>
<li><a href="scripting_languages/python.html">Python</a></li>
<li><a href="scripting_languages/bash.html">Bash</a></li>
<li><a href="scripting_languages/unixshell.html">Unix Shell Script</a></li>
<li><a href="scripting_languages/php.html">PHP</a></li>
</ul>
</li>
<li>
<a href="operating_system/os.html">Operating System</a>
<ul>
<li><a href="operating_system/windows.html">Windows</a></li>
<li><a href="operating_system/linux.html">Linux</a></li>
<li><a href="operating_system/mac.html">Mac</a></li>
</ul>
</li>
<li>
<a href="about/aboutme.html">About Me</a>
<ul>
<li><a href="about/CV.html">CV</a></li>
<li><a href="about/reflection.html">Reflection</a></li>
<li><a href="about/portfolio.html">Portfolio</a></li>
</ul>
</li>
</ul>
</nav>`
编辑; 我的网站到目前为止没有更改并使用上面的代码
用 Ema4rl 的解决方案和<?php include 'page.php';?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="google-site-verification" content="MCQUXJvcfRxBpOiSL14SrYWBsaiaXT8xB_LunwccElI" />
<title>Homepage</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<!-- CSS here -->
<link rel="stylesheet" type="text/css" href="template.css">
<!-- JavaScript here -->
<script src="externalscript.js" type="text/javascipt"></script>
<!-- PHP here -->
<!-- Python here -->
</head>
<body>
<div class="nested">
<div class="header">
<div class="logo">
<a href="/index.html"><img src="../images/codex.jpg" alt="echo Codex" width="154" height="156" class="topleft"/></a>
</div>
<div class="title">
<br>
<h1>Codex</h1>
<h4><b>Scientia Potentia Est. Knowledge is Power</b></h4>
</div>
<div class="search">
<script>
(function() {
var cx = '002444324895425384483:h-an5qvcpci';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
</div>
<div class="menu">
<?php include 'page.php';?>
</div>
<div class="main">
<div class="sidebar">
<ul>
<li><a href="sitemap.html">Sitemap</a></li>
<li><a href="/contact.html">Contact Us</a></li>
</ul>
</div>
<div class="content">
<h1>Welcome to the Castillo's Vault</h1>
<p>This website is built for general and specific knowledges about the world of computing such as</p>
<ul>
<li>Coding</li>
<li>Rules of coding</li>
<li>Operating System</li>
<li>Hacking world</li>
<li>Portfolio</li>
<li>CV</li>
<li>And much more</li>
</ul>
<p>At the moment, I am designing the webpages by using Notepad++. It will take a long time until the website is at the stage where I feel like it is completed. The website is not even nearly done.</p>
<p>The website will be continuously being updated. There are always new information that are being released about the world of Internet and its medium. The medium are the computers which can be divided into desktop, laptop, tablet, even mobile phone.</p>
<p>This website is created by Hugo-Daniel Castillo for the purpose of education and revising. If there is any queries or comments, please email hugodanielcastillo@vaultofcastillo.comuv.com</p>
<br>
</div>
</div>
<div class="end">
<footer>
<p>Made by Hugo-Daniel Castillo <br>Coventry University Student<br>Ethical Hacking and Networking Security</p>
</footer>
</div>
</div>
</body>
</html>
【问题讨论】:
-
如果您使用 html,您可以为链接创建一个 xml 文件,也可以创建一个 php 文件,甚至可以从数据库中提取链接。什么你只使用 php 或 php 框架?
-
<?php include 'nav.php';?> -
@DanteFañaBadia,如果我使用 name.html 而不是 name.php 可以吗?如果是后一种选择,我是否必须将 html 文件重新定义为 php?我还不确定PHP。我对那种语言不是很流利。
-
@Hugo-DanielCastillo 您需要重命名所有文件,否则服务器将无法理解 php 代码。