私は最初の本当の php Web アプリを構築しています。多くの人が知っているように、これにはたくさんのページを作成する必要があります。
反復的なものを合理化しようとして、私はほとんどのものを次のような content.php ページ内に配置しました
<?php include_once ('config3.inc');?>
<?php if(isset($_GET['p'])){
$page = $_GET['p'];
}else {
$page ='';
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $_SERVER['PHP_SELF'];?></title>
<?php include('styles.inc');?>
<?php include('api.inc'); ?>
<?php include('scripts.inc');?>
</head>
<body>
<div id="container">
<?php include ('header.inc');?>
<div><!-- Content -->
<?php include ('./content/'.$page);?>
</div>
</div><!-- end container -->
<!-- Footer -->
<?php include ('footer.inc');?>
</body>
</html>
このようにして、ページを呼び出したいときに www.domain.com/content.php?p=pagename.php にアクセスすると、すべてが正しいスタイル シート コンテナーやフッターなどに「ラップ」されます。
ページ名に POST データを使用する必要がある CRUD ページを作成するまでは、うまく機能していました。
これにはより良いアプローチがありますか、それともこのアプローチを完全に廃止する必要がありますか?