2016-09-14 16:27
浏览 11


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.

图片转代码服务由CSDN问答提供 功能建议

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

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

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

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

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dougao9864 2016-09-14 16:51

    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)

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

    The PHP File (whatever.php)

    include 'headerClass.php';
    $getHl = $_GET['hl'];
    $getHeader = new hlText();
    $theHeader = $getHeader->gethlText($getHl);
     <!DOCTYPE html>
        <title>Page Title</title>
        <h1><?php echo $theHeader; ?></h1>
    点赞 打赏 评论

相关推荐 更多相似问题