doucuoyan0426 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.

  • 写回答

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)

    <?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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么改成循环输入删除(语言-c语言)
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题