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 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable