0

約 50 ページあり、それぞれにヘッダー部分のインクルードが含まれています。

include './include/header.php';

header.php次のようなコードが含まれています。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>

しかし今、約 20 ページについて Google Experiments を実施したいと考えており、それらの A/B バージョンが必要です。

<head>Google では、元のページで、タグの直後に各実験の個別のコード ブロックを追加する必要があります。

<head>
//type 1 block of code for page 1 //
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<head>
//type 2 block of code for page 2 //
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

等々。

これを処理する最も簡単でスマートな方法は何ですか?

編集:

わかりました、次のように編集する必要があると思いますheader.php

<!DOCTYPE html>
<html>
<head>
<?php if  ($experiment==true) { ?>     // New      
[some way to insert block of code ]   // New           
<?php } else { } ?> // New
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>

そして、実験を行う必要がある個々のページごとに、ページの上部に次のコードを追加します。

$experiment = "big block of code 1"

しかし、どうすれば正確にそれを行うことができますか?

4

0 に答える 0