什麼是最好的方法? 我用這樣的方式...... 的index.php <?php
$secure = true;
include_once("file.php");
?>
我不想打開file.php直接。 所以在第一行我寫了這個代碼: file.php <?php
// first line I wrote this code:
if(!isset($secure)) exit
我所有的PHP包括文件是在一個目錄: https://www.mywebsite.com/includes
插入在頂層網頁這些文件是很容易的: <?php include 'includes/logo.php'; ?>
<?php include 'includes/main_nav.php'; ?>
<?php include 'includes/news.php'; ?>
etc.