[英]Code structuring - How to include a file (JS, PHP, etc...) into HTML
你好嗎?
我想盡可能仔細地構建我的代碼,但我不知道該怎么做。 在單個文件中,我有 PHP、JS 和 HTML 代碼,我想知道是否可以通過在 html 代碼中包含它們的“路徑”來分隔內容。
例如,我如何將 php 代碼和 js 代碼分開:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
{ js code }
{ php code }
</body>
</html>```
Thank you in advance for the information I would receive
您可以使用“.php”文件作為默認文件,然后將 html 放入其中
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="file.js"></script>
<?php include('file.php') ?>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.