动态着陆页标题(不是来自关键字)[已关闭]

动态着陆页标题(不是来自关键字)[已关闭]

问题描述:

I'm creating a set of display ads in Google that all go to the same landing page. The only thing is that I need a specific headline to display based on whichever ad is clicked on. I'll be differentiating the ads by using URL parameters, however, I don't want to put the full headline text in the URL parameter because the headlines are fairly long.

What I think I need to do is have a coded parameter, such as "/?hl=2", and then use that to dynamically replace the text in the h1 tags with "Headline ABC" or whatever that headline associated with that parameter would be.

Would the best way to do this be through a series of javascript if statements? Or through some sort of php array?

Any suggestions would be appreciated. Unfortunately, I've only been able to find resources about keyword insertion online, not custom headlines.

我正在Google中创建一组展示广告,这些广告都会转到同一个目标网页。 唯一的问题是我需要根据点击的广告显示特定标题。 我将通过使用网址参数区分广告,但是,我不想将完整的标题文字放在网址参数中,因为标题相当长。 p>

我的想法 我需要做的是有一个编码参数,例如“/?hl = 2”,然后使用它来动态地用“标题ABC”替换h1标签中的文本或者与该参数相关联的标题。

最好的方法是通过一系列javascript if语句吗? 或者通过某种php数组? p>

任何建议都将不胜感激。 不幸的是,我只能找到有关在线关键字插入的资源,而不是自定义标题。 p> div>

I would suggest creating a PHP class and calling a set function that selects the correct text using a switch statement. This is what I have below.

The Class File (headerClass.php)

<?php
    class hlText{

        public function gethlText($selectedHl){
            switch ($selectedHl) {
                case 1:
                $returnedValue = "The First Header";
                break;
                case 2:
                $returnedValue = "The Second Header";
                break;
                case 3:
                $returnedValue = "The Third Header";
                break;
                default:
                $returnedValue = "The Default Header";
            }
            return $returnedValue;
        }

    }
?>

The PHP File (whatever.php)

<?php 

include 'headerClass.php';

$getHl = $_GET['hl'];

$getHeader = new hlText();

$theHeader = $getHeader->gethlText($getHl);

?>

 <!DOCTYPE html>
 <html>
 <head>
    <title>Page Title</title>
 </head>
 <body>

    <h1><?php echo $theHeader; ?></h1>

 </body>
 </html>